I defined a job with Quartz that calls a web service. I have a trigger with Cron expression which run every 50 minutes as 0 0/50 * ? * * *
0 0/50 * ? * * *
. I have a requirement that execute the job in startup application and after that every 50 minutes.
the job factory is:
Trigger trigger = newTrigger().withIdentity(name, "our.trigger")
.withSchedule(CronScheduleBuilder.cronSchedule("0
0/50 * ? * * *")).startNow().build();
JobDetail jobDetail = newJob(jobClass).withIdentity(name, "our.job").build();
Set<Trigger> triggers = new HashSet<>();
triggers.add(trigger);
stdScheduler.scheduleJob(jobDetail, triggers, true);
stdScheduler.start();
How do I solve this issue?
I solved the problem with the following code:
Trigger startupTrigger = newTrigger().withIdentity(name+".startup", "trigger")
.withSchedule(SimpleScheduleBuilder.repeatSecondlyForTotalCount(1)).startNow().build();
Thanks for @biiyamn
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.