diff --git a/code/Executable/DependencyInjection/QuartzDI.cs b/code/Executable/DependencyInjection/QuartzDI.cs index 73315faf..31b1ea40 100644 --- a/code/Executable/DependencyInjection/QuartzDI.cs +++ b/code/Executable/DependencyInjection/QuartzDI.cs @@ -55,7 +55,7 @@ public static class QuartzDI if (contentBlockerConfig?.Enabled is true && queueCleanerConfig is { Enabled: true, RunSequentially: true }) { q.AddJob(queueCleanerConfig, string.Empty); - q.AddJobListener(new JobChainingListener(nameof(QueueCleaner))); + q.AddJobListener(new JobChainingListener(nameof(ContentBlocker), nameof(QueueCleaner))); } else { diff --git a/code/Infrastructure/Verticals/Jobs/JobChainingListener.cs b/code/Infrastructure/Verticals/Jobs/JobChainingListener.cs index b9f5c8c9..273f3b4d 100644 --- a/code/Infrastructure/Verticals/Jobs/JobChainingListener.cs +++ b/code/Infrastructure/Verticals/Jobs/JobChainingListener.cs @@ -4,10 +4,12 @@ namespace Infrastructure.Verticals.Jobs; public class JobChainingListener : IJobListener { + private readonly string _firstJobName; private readonly string _nextJobName; - public JobChainingListener(string nextJobName) + public JobChainingListener(string firstJobName, string nextJobName) { + _firstJobName = firstJobName; _nextJobName = nextJobName; } @@ -19,7 +21,7 @@ public class JobChainingListener : IJobListener public async Task JobWasExecuted(IJobExecutionContext context, JobExecutionException? jobException, CancellationToken cancellationToken) { - if (string.IsNullOrEmpty(_nextJobName) || context.JobDetail.Key.Name == _nextJobName) + if (string.IsNullOrEmpty(_nextJobName) || context.JobDetail.Key.Name == _nextJobName || context.JobDetail.Key.Name != _firstJobName) { return; }