fix: new variable for group name

This commit is contained in:
Guillermo Marcel 2025-02-15 16:05:11 -03:00
parent 8fbe439ed4
commit 27dfcb291a

View File

@ -35,19 +35,20 @@ public class AutoScanApp
await _scheduler.Start(cancellationToken); await _scheduler.Start(cancellationToken);
_logger.LogDebug("Scheduler started successfully!"); _logger.LogDebug("Scheduler started successfully!");
const string group = "ScanGroup"; const string groupName = "ScanGroup";
IJobDetail downloaderJob = JobBuilder.Create<DownloaderJob>() IJobDetail downloaderJob = JobBuilder.Create<DownloaderJob>()
.WithIdentity("downloader", group) .WithIdentity("downloader", groupName)
.Build(); .Build();
//Job with no trigger but tied to the chainer to be executed after the downloader job
IJobDetail scannerJob = JobBuilder.Create<ScannerJob>() IJobDetail scannerJob = JobBuilder.Create<ScannerJob>()
.WithIdentity("scanner", group) .WithIdentity("scanner", groupName)
.StoreDurably(true) .StoreDurably()
.Build(); .Build();
ITrigger trigger = TriggerBuilder.Create() ITrigger trigger = TriggerBuilder.Create()
.WithIdentity("trigger1", group) .WithIdentity("trigger1", groupName)
.WithCronSchedule(cron) .WithCronSchedule(cron)
.StartNow() .StartNow()
.Build(); .Build();
@ -55,7 +56,7 @@ public class AutoScanApp
var chainer = _chainerListenerFactory.CreateChainerListener("Scan Chainer"); var chainer = _chainerListenerFactory.CreateChainerListener("Scan Chainer");
chainer.AddJobChainLink(downloaderJob.Key, scannerJob.Key); chainer.AddJobChainLink(downloaderJob.Key, scannerJob.Key);
_scheduler.ListenerManager.AddJobListener(chainer, GroupMatcher<JobKey>.GroupEquals(group)); _scheduler.ListenerManager.AddJobListener(chainer, GroupMatcher<JobKey>.GroupEquals(groupName));
await _scheduler.ScheduleJob(downloaderJob, trigger, cancellationToken); await _scheduler.ScheduleJob(downloaderJob, trigger, cancellationToken);
await _scheduler.AddJob(scannerJob, false, true, cancellationToken); await _scheduler.AddJob(scannerJob, false, true, cancellationToken);