I want to chain the 3 jobs, but AddJobChainLink() gets only 2 jobKeys as parameter.
scheduler = container.GetInstance<IScheduler>();
scheduler.JobFactory = container.GetInstance<IJobFactory>(); JobKey jobkey1 = new JobKey("job1", "group1");
JobKey jobkey2 = new JobKey("job2", "group2");
JobKey jobkey3 = new JobKey("job3", "group3");
var job1 = JobBuilder.Create<Type1>().WithIdentity("job1", "group1").Build();
var job2 = JobBuilder.Create<Type2>().WithIdentity("job2", "group2").Build();
var job3 = JobBuilder.Create<Type3>().WithIdentity("job3", "group3").Build();
ITrigger trigger1 = TriggerBuilder.Create().WithIdentity("trigger1", "group1").StartNow().Build();
JobChainingJobListener chain = new JobChainingJobListener("testChain");
chain.AddJobChainLink(jobkey1, jobkey2);
scheduler.ScheduleJob(job1, trigger1);
scheduler.AddJob(job2, true);
scheduler.AddJob(job3, true);
scheduler.ListenerManager.AddJobListener(chain, GroupMatcher<JobKey>.AnyGroup());
scheduler.Start();
Try this:
JobChainingJobListener chain = new JobChainingJobListener("testChain");
chain.AddJobChainLink(jobkey1, jobkey2);
chain.AddJobChainLink(jobkey2, jobkey3);
JobChainingJobListener
helps you create a chain of execution for your jobs in a specific order you desire. You just need to chain each job with another in specific order.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With