Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Interrupting a job in quartz cluster

I have a Quartz setup with multiple instances and I want to interrupt a job wherever it is executed. As it was said in documentation, Scheduler.interrupt() method is not cluster aware so I'm looking for some common practice to overcome such limitation.

like image 719
Alexander Oleynikov Avatar asked Oct 25 '12 10:10

Alexander Oleynikov


1 Answers

Well, here are some basics you should use to achieve that.

When running in cluster mode, the information about the currently running jobs are available in the quartz tables. For instance, the q_fired_triggers contains the job being executed. The first column of this table is the scheduler name being in charge of it. So it is pretty easy to know who is doing what.

Then, if you enable the JMX export of your quartz instances org.quartz.scheduler.jmx.export, the MBeans you will enable a new entry point to remotely manage each scheduler individually. The MBean provides a method boolean interruptJob("JobName", "JobGroup")

Then you "just" need to call this method on the appropriated scheduler instance to effectively interrupt it.

I tried all the process manually and it works fine, just need to be automatized :)

HIH

like image 80
poussma Avatar answered Sep 18 '22 18:09

poussma