I'm new to quartz in java and I should use it in my web developing project and I want a scheduler which fires every Wednesday on 12 pm. .I found on the internet that I should use Crontrigger with this:
CronTrigger trigger=new CronTrigger();
try {
trigger.setCronExpression("30 43 20 ?开发者_运维知识库 * WED");
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
now I want to set misfire instructions, which I think is my solution to my purpose, but I couldn't find good instructions.
I have a draw in my website scheduled with this trigger. I want to do something special if a misfire issue happens for example if server is down I want to do it again or something else.
In the internet I found listeners and setmisfireInstruction method but I don't know which one I should use and how.
Thanks for you help
You need to call setMisfireInstruction()
on your CronTrigger
object. See javadoc.
For quartz api 2.x you can use withMisfireHandlingInstructionFireAndProceed() function as below. Api Docs
CronScheduleBuilder.cronSchedule("30 43 20 ? * WED").withMisfireHandlingInstructionFireAndProceed();
精彩评论