Fixed email sending logic #20

Merged
khwezi merged 1 commits from migration into master 2026-05-16 00:33:04 +02:00
5 changed files with 16 additions and 7 deletions
@@ -17,11 +17,12 @@
<!-- Lite Charms Libraries -->
<ItemGroup>
<PackageReference Include="LiteCharms.Features" Version="1.27.0" />
<PackageReference Include="LiteCharms.Features" Version="1.32.0" />
</ItemGroup>
<!-- Shared Global Usings -->
<ItemGroup>
<Using Include="Quartz" />
<Using Include="Mediator" />
</ItemGroup>
</Project>
+6 -3
View File
@@ -1,12 +1,15 @@
using LiteCharms.Features.Extensions;
using LiteCharms.Features.Mediator;
using LiteCharmsScheduler.Workers;
using Mediator;
using static LiteCharms.Features.Email.Extensions.Constants;
var builder = Host.CreateApplicationBuilder(args);
builder.Services.AddMediator();
builder.Services.AddMediator(options => options.Assemblies = new List<AssemblyReference>
{
typeof(Program).Assembly,
typeof(LiteCharms.Features.Shop.Notifications.Events.ProcessEmailNotificationsEvent).Assembly
}.AsReadOnly());
builder.Services.AddScoped(typeof(IPipelineBehavior<,>), typeof(TelemetryPipelineBehavior<,>));
builder.Services.AddScoped(typeof(IPipelineBehavior<,>), typeof(LoggingPipelineBehavior<,>));
@@ -16,7 +19,7 @@ builder.Services.AddEmailServiceBus();
builder.Services.AddSalesServiceBus();
builder.Services.AddGeneralServiceBus();
builder.Services.AddQuartzSchedulerClient(ShopSchedulerName, builder.Configuration);
builder.Services.AddQuartzScheduler(ShopSchedulerName, builder.Configuration);
builder.Services.AddShopServices();
builder.Services.AddShopDatabase(builder.Configuration);
+5 -1
View File
@@ -5,9 +5,13 @@ namespace LiteCharmsScheduler.Workers
{
public class JobWorker(IJobOrchestrator jobOrchestrator, ILogger<JobWorker> logger) : BackgroundService
{
private const string emailProcessorCron = "0 */5 * * * ?";
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
{
await jobOrchestrator.ScheduleAsync(ProcessEmailNotificationsEvent.Create(), "0 */5 * * * ?", stoppingToken);
var emailProcessorJob = ProcessEmailNotificationsEvent.Create();
await jobOrchestrator.ScheduleAsync(emailProcessorJob, emailProcessorCron, stoppingToken);
logger.LogInformation("Startup jobs scheduled");
}
+2 -1
View File
@@ -15,7 +15,8 @@
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
"Microsoft.AspNetCore": "Warning",
"Microsoft.EntityFrameworkCore": "Warning"
}
},
"AllowedHosts": "*"
+1 -1
View File
@@ -51,7 +51,7 @@ metadata:
namespace: litecharms-scheduler-uat
spec:
serviceName: "scheduler-worker-service"
replicas: 3
replicas: 1
selector:
matchLabels:
app: scheduler