Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 61172c6139 |
@@ -34,7 +34,7 @@ public static class Quartz
|
|||||||
storage.UseClustering(cluster =>
|
storage.UseClustering(cluster =>
|
||||||
{
|
{
|
||||||
cluster.CheckinInterval = TimeSpan.FromSeconds(30);
|
cluster.CheckinInterval = TimeSpan.FromSeconds(30);
|
||||||
cluster.CheckinMisfireThreshold = TimeSpan.FromSeconds(90);
|
cluster.CheckinMisfireThreshold = TimeSpan.FromSeconds(20);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -62,8 +62,6 @@ public static class Quartz
|
|||||||
config.UseDefaultThreadPool(options => options.MaxConcurrency = 1);
|
config.UseDefaultThreadPool(options => options.MaxConcurrency = 1);
|
||||||
config.UseTimeZoneConverter();
|
config.UseTimeZoneConverter();
|
||||||
|
|
||||||
config.SetProperty("quartz.jobStore.misfireThreshold", TimeSpan.FromMinutes(2).TotalMilliseconds.ToString());
|
|
||||||
|
|
||||||
config.UsePersistentStore(storage =>
|
config.UsePersistentStore(storage =>
|
||||||
{
|
{
|
||||||
storage.PerformSchemaValidation = false;
|
storage.PerformSchemaValidation = false;
|
||||||
@@ -76,7 +74,7 @@ public static class Quartz
|
|||||||
storage.UseClustering(cluster =>
|
storage.UseClustering(cluster =>
|
||||||
{
|
{
|
||||||
cluster.CheckinInterval = TimeSpan.FromSeconds(30);
|
cluster.CheckinInterval = TimeSpan.FromSeconds(30);
|
||||||
cluster.CheckinMisfireThreshold = TimeSpan.FromSeconds(90);
|
cluster.CheckinMisfireThreshold = TimeSpan.FromSeconds(20);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -50,9 +50,9 @@ public class JobOrchestrator(ISchedulerFactory schedulerFactory) : IJobOrchestra
|
|||||||
|
|
||||||
var trigger = global::Quartz.TriggerBuilder.Create()
|
var trigger = global::Quartz.TriggerBuilder.Create()
|
||||||
.WithIdentity(triggerKey)
|
.WithIdentity(triggerKey)
|
||||||
.WithDescription($"Scheduled via Main Job at {now:g}")
|
.WithDescription($"Scheduled via Main Job at {now:g} UTC")
|
||||||
.WithCronSchedule(cronExpression, cron => cron
|
.WithCronSchedule(cronExpression, cron => cron
|
||||||
.WithMisfireHandlingInstructionIgnoreMisfires())
|
.WithMisfireHandlingInstructionFireAndProceed())
|
||||||
.StartAt(now)
|
.StartAt(now)
|
||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
|
|||||||
@@ -10,28 +10,16 @@ public class MediatorJob<TNotification>(IMediator mediator) : IJob where TNotifi
|
|||||||
{
|
{
|
||||||
var data = context.MergedJobDataMap["Payload"] as string;
|
var data = context.MergedJobDataMap["Payload"] as string;
|
||||||
|
|
||||||
if (string.IsNullOrWhiteSpace(data))
|
if (string.IsNullOrWhiteSpace(data)) return;
|
||||||
{
|
|
||||||
Trace.WriteLine("Job Payload missing, job ended");
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var notification = JsonSerializer.Deserialize<TNotification>(data);
|
var notification = JsonSerializer.Deserialize<TNotification>(data);
|
||||||
|
|
||||||
if (notification is null)
|
if (notification is null) return;
|
||||||
{
|
|
||||||
Trace.WriteLine("Notification could not be JSon converted from data string, job ended");
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
using var activity = MediatorTelemetry.Source.StartActivity($"Quartz: {typeof(TNotification).Name}");
|
using var activity = MediatorTelemetry.Source.StartActivity($"Quartz: {typeof(TNotification).Name}");
|
||||||
|
|
||||||
activity?.SetTag("event.correlation_id", notification.CorrelationId);
|
activity?.SetTag("event.correlation_id", notification.CorrelationId);
|
||||||
|
|
||||||
await mediator.Publish(notification, context.CancellationToken);
|
await mediator.Publish(notification, context.CancellationToken);
|
||||||
|
|
||||||
Trace.WriteLine("Job published");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
-6
@@ -13,8 +13,6 @@ public class ProcessEmailNotificationsEventHandler(IDbContextFactory<ShopDbConte
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
logger.LogInformation("Started");
|
|
||||||
|
|
||||||
using var context = await contextFactory.CreateDbContextAsync(cancellationToken);
|
using var context = await contextFactory.CreateDbContextAsync(cancellationToken);
|
||||||
|
|
||||||
var notifications = await context.Notifications
|
var notifications = await context.Notifications
|
||||||
@@ -54,10 +52,6 @@ public class ProcessEmailNotificationsEventHandler(IDbContextFactory<ShopDbConte
|
|||||||
{
|
{
|
||||||
logger.LogError(ex, ex.Message);
|
logger.LogError(ex, ex.Message);
|
||||||
}
|
}
|
||||||
finally
|
|
||||||
{
|
|
||||||
logger.LogInformation("Finished");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<Result> SendEmailAsync(Notification notification, EmailService service, CancellationToken cancellationToken = default)
|
private async Task<Result> SendEmailAsync(Notification notification, EmailService service, CancellationToken cancellationToken = default)
|
||||||
|
|||||||
Reference in New Issue
Block a user