Hi, I have multiple quartz cron jobs in a load balanced environment. Currently these jobs are running on each node, which is not desirable. I want a node to run only a particular scheduler and if the node crashes, another node should run the scheduler intended for the node that crashed. How can this be done with spring 2.5.6/tomcat load balancer.
I think there's a few aspects to this question.
Firstly, Quartz has API methods for pausing and resuming the Scheduler, or even individual triggers and jobs
I would create a spring bean with a reference to the Quartz scheduler or trigger, and a simple isMasterNode boolean member for storing state. I'd then expose 2 [restricted-access] web service calls: makeMaster and makeSlave, which will call Scheduler.resume() or standby/pause, respectively.
Finall, the big question is how & with what you determine that another node has 'crashed'.
If you're using a hardware loadbalancer to manage this, you could configure it to call the 'makeMaster' WS on the new 'primary' node, which in turn calls Scheduler.resume() or similar.
hth
Thanks for the answer. Though I could not understand the reasoning for Mater or Slave in a load balancer. So here is the problem in a little more detail : I have two instances of Tomcat t1, t2 both sharing load for my web app equally, but running on two separate jvms. Since the war file deployed is the same on both instances the scheduler will kick off the same jobDetailBean method at the same time. This will cause a problem since the same method will be executed twice. Hope I was able to describe the problem better than before.