anuni
anuni

Reputation: 999

How can I ensure a spring quartz job executed sequentially?

I have below trigger config:

SimpleTrigger trigger = TriggerBuilder.newTrigger().startNow()
    .withSchedule(SimpleScheduleBuilder.repeatSecondlyForever(5)).build();

And my job could possibly run more than 5 seconds.

Which means there could be chances that 2 job instances run at the same time.

Is there any policy I can enforce on quartz scheduler:

if job is running, do not fire next one even if reach the repeat interval.

Is it doable?

Thanks

Upvotes: 1

Views: 461

Answers (1)

user06062019
user06062019

Reputation: 691

Try using this annotation @DisallowConcurrentExecution.This should not allow executing of same instance of a Job https://www.quartz-scheduler.org/api/2.1.7/org/quartz/DisallowConcurrentExecution.html

Upvotes: 1

Related Questions