gpt4 book ai didi

c# - 如何使用 JobChainingJobListener Quartz.net 链接 2 个以上的作业?

转载 作者:太空狗 更新时间:2023-10-29 21:22:06 29 4
gpt4 key购买 nike

我想链接这 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();

最佳答案

试试这个:

JobChainingJobListener chain = new JobChainingJobListener("testChain");
chain.AddJobChainLink(jobkey1, jobkey2);
chain.AddJobChainLink(jobkey2, jobkey3);

JobChainingJobListener 可帮助您按照所需的特定顺序为作业创建执行链。您只需要按特定顺序将每个作业与另一个作​​业链接起来。

关于c# - 如何使用 JobChainingJobListener Quartz.net 链接 2 个以上的作业?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29368054/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com