Thursday, August 27, 2009

Quartz: pause all running jobs

We have a requirement to pause quartz jobs while complex changes are being made to our webapp.Use Scheduler.pauseAll() to pause them. This will pause future triggering of jobs but it doesn't stop jobs which are currently running.

To find if any jobs are running currently, size of scheduler.getCurrentlyExecutingJobs() list can be checked. Check this in a simple while loop till size is zero.

Scheduler.resumeAll() is the counterpart of pauseAll().