我想链接3个作业,但AddJobChainLink()只获得2个jobKeys作为参数。
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();
答案 0 :(得分:8)
试试这个:
JobChainingJobListener chain = new JobChainingJobListener("testChain");
chain.AddJobChainLink(jobkey1, jobkey2);
chain.AddJobChainLink(jobkey2, jobkey3);
JobChainingJobListener
可帮助您按照所需的特定顺序为作业创建执行链。您只需要按特定顺序将每个作业与另一个作业链接起来。