Quartz.NET设置MisfireInstruction [英] Quartz.NET setting MisfireInstruction
问题描述
我正在使用Quartz.NET在C#中工作,并且在CronTrigger上设置失火指令时遇到问题.我正在运行安装了Quartz DB的SQL后端.我有以下代码可以很好地用于创建作业和运行计划程序.
I'm working in C# using Quartz.NET and am having problems setting the misfire instruction on a CronTrigger. I'm running an SQL backend with the Quartz DB installed. I have the following code which works fine for creating a job and running a scheduler.
IScheduler _scheduler;
IJobDetail job;
ISchedulerFactory sFactory;
ICronTrigger trig;
sFactory = new StdSchedulerFactory();
_scheduler = sFactory.GetScheduler();
_scheduler.Start();
job = JobBuilder.Create<Test>().WithIdentity("testJob", "testGroup").Build();
trig = (ICronTrigger) TriggerBuilder.Create().WithIdentity("testTrigger", "testGroup").WithCronSchedule("0/10 * * * * ?").Build(); int i = trig.MisfireInstruction;
_scheduler.ScheduleJob(job, trig);
我唯一可以访问的误启动指令是trig.MisfireInstruction
,它是一个整数,我无法设置它.
在CronScheduleBuilder中,还有WithMisfireHandlingInstruction
开头的一些函数.
The only misfireinstruction I can access is trig.MisfireInstruction
which is an int, and I can't set it.
There are also some functions beginning WithMisfireHandlingInstruction
in CronScheduleBuilder.
推荐答案
您的触发器创建应如下所示:
Your trigger creation should be like this:
trig = (ICronTrigger)TriggerBuilder
.Create()
.WithIdentity("testTrigger", "testGroup")
.WithCronSchedule("0/10 * * * * ?", x => x.WithMisfireHandlingInstructionFireAndProceed())
.Build();
您可以使用以下选项:
- WithMisfireHandlingInstructionDoNothing
- WithMisfireHandlingInstructionFireAndProceed
- WithMisfireHandlingInstructionIgnoreMisfires
您可以在此处找到很好的解释.
You can find a good explanation here.
这篇关于Quartz.NET设置MisfireInstruction的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!