Job reschedule itself after completion using Quartz

I want to run a job and, as soon as it finishes, it should start again, forever.

How can I manage this using Quartz?

Further information will be provided if requested.

Thanks

Answer

you’ll want to look at the TriggerBuilder which can build a trigger with repeatsForever() to get a repeating job.

http://www.quartz-scheduler.org/api/2.2.0/index.html?org/quartz/Trigger.html

     JobDetail job = newJob(MyJob.class)
         .withIdentity("myJob")
         .build();

     Trigger trigger = newTrigger() 
         .withIdentity(triggerKey("myTrigger", "myTriggerGroup"))
         .withSchedule(simpleSchedule()
             .withIntervalInHours(1)
             .repeatForever())
         .startAt(futureDate(10, MINUTES))
         .build();

     scheduler.scheduleJob(job, trigger);

Leave a Reply

Your email address will not be published. Required fields are marked *