Jobs not chaining using JobChainingJobListener

房东的猫 提交于 2019-11-29 07:52:31

The issue here is that you have misspelled the key the second time ("Job1" vs "job1") which causes there to be no known link to fire. Here's updated code sample with redundancies removed.

var scheduler = StdSchedulerFactory.GetDefaultScheduler();
JobKey jobKey1 = new JobKey("job1", "group1");
JobKey jobKey2 = new JobKey("job2", "group2");

var job1 = JobBuilder.Create<Test1>().WithIdentity(jobKey1).Build();
var job2 = JobBuilder.Create<Test2>().WithIdentity(jobKey2).StoreDurably(true).Build();

ITrigger trigger1 = TriggerBuilder.Create()
   .WithIdentity("trigger1", "group1")
   .StartNow()
   .Build();

JobChainingJobListener chain = new JobChainingJobListener("testChain");
chain.AddJobChainLink(jobKey1, jobKey2);
scheduler.ListenerManager.AddJobListener(chain, GroupMatcher<JobKey>.AnyGroup());

scheduler.ScheduleJob(job1, trigger1);
scheduler.AddJob(job2, true);

scheduler.Start();

The scheduler.addGlobalJobListener is old API and longer part of 2.x series. You should use the ListenerManager like you have done.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!