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);
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.
A misfire occurs if a persistent trigger “misses” its firing time because of the scheduler being shutdown, or because there are no available threads in Quartz's thread pool for executing the job. The different trigger types have different misfire instructions available to them.
Trigger - a component that defines the schedule upon which a given Job will be executed. JobBuilder - used to define/build JobDetail instances, which define instances of Jobs.
Your trigger creation should be like this:
trig = (ICronTrigger)TriggerBuilder
.Create()
.WithIdentity("testTrigger", "testGroup")
.WithCronSchedule("0/10 * * * * ?", x => x.WithMisfireHandlingInstructionFireAndProceed())
.Build();
you can use these options:
You can find a good explanation here.
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