Fix multiple runs on queue cleaner when download cleaner is enabled (#90)
This commit is contained in:
@@ -55,7 +55,7 @@ public static class QuartzDI
|
|||||||
if (contentBlockerConfig?.Enabled is true && queueCleanerConfig is { Enabled: true, RunSequentially: true })
|
if (contentBlockerConfig?.Enabled is true && queueCleanerConfig is { Enabled: true, RunSequentially: true })
|
||||||
{
|
{
|
||||||
q.AddJob<QueueCleaner>(queueCleanerConfig, string.Empty);
|
q.AddJob<QueueCleaner>(queueCleanerConfig, string.Empty);
|
||||||
q.AddJobListener(new JobChainingListener(nameof(QueueCleaner)));
|
q.AddJobListener(new JobChainingListener(nameof(ContentBlocker), nameof(QueueCleaner)));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -4,10 +4,12 @@ namespace Infrastructure.Verticals.Jobs;
|
|||||||
|
|
||||||
public class JobChainingListener : IJobListener
|
public class JobChainingListener : IJobListener
|
||||||
{
|
{
|
||||||
|
private readonly string _firstJobName;
|
||||||
private readonly string _nextJobName;
|
private readonly string _nextJobName;
|
||||||
|
|
||||||
public JobChainingListener(string nextJobName)
|
public JobChainingListener(string firstJobName, string nextJobName)
|
||||||
{
|
{
|
||||||
|
_firstJobName = firstJobName;
|
||||||
_nextJobName = nextJobName;
|
_nextJobName = nextJobName;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -19,7 +21,7 @@ public class JobChainingListener : IJobListener
|
|||||||
|
|
||||||
public async Task JobWasExecuted(IJobExecutionContext context, JobExecutionException? jobException, CancellationToken cancellationToken)
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user