Search code examples
javascheduled-tasksquartz-schedulerschedule

How to interrupt or stop currently running quartz job?


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?


Solution

  • You need to write 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).