How to interrupt or stop currently running quartz job?

breedish picture breedish · Aug 23, 2011 · Viewed 57.5k times · Source

I have some tasks that are executed with the help of Java Quartz Jobs, but I need to stop some tasks by some condition in my code. I read that this can be done via InterruptableJob. But i didn't understand in what way i should do it?

Answer

blob picture blob · Aug 23, 2011

You need to write a your job as an implementation of InterruptableJob. To interrupt this job, you need handle to Scheduler , and call interrupt(jobKey<<job name & job group>>)

Please have a look @ javadoc for above classes, also quartz distribution contains an example for this (example7).