usphisics
usphisics

Reputation: 141

JAVA Quartz - Skip job if previous is still running AND wait for the next schedule time

I have a Java solution that uses Quartz 2.2.3, and what I have is:

This is my problem, I don't want to make the second job wait if the previous didn't finish, I want to skip the second one and when the time turns 3pm the job can run. Reading javadoc I added the withMisfireHandlingInstructionDoNothing() but it didn't work.

I think I'm doing something wrong or missing something.

My code:

Scheduler scheduler = StdSchedulerFactory.getDefaultScheduler();

JobDetail job = JobBuilder.newJob(TestCronService.class).withIdentity("testA","testB").build();


CronTrigger trigger = TriggerBuilder.newTrigger().withIdentity("testA","testB")
.withSchedule(CronScheduleBuilder.cronSchedule("0 0 * * * ?")
.withMisfireHandlingInstructionDoNothing())
.build();


scheduler.scheduleJob(job, trigger);
scheduler.start();

Upvotes: 13

Views: 10372

Answers (1)

nava
nava

Reputation: 81

Change the function :

withMisfireHandlingInstructionDoNothing() 

with

withMisfireHandlingInstructionNextWithRemainingCount()

Upvotes: 8

Related Questions