Spring schedulers in a load balanced environment
I have multiple quartz cron jobs in a load balanced environment. Currently, these jobs run on every node, which is not desirable. I want a node to only start a specific scheduler, and if a node crashes, the other node has to start a scheduler that targets the crashed node. How can this be done with spring 2.5.6 / tomcat load balancer.
source to share
I think there are several aspects to this question.
First, Quartz has API methods to pause and resume the Scheduler, or even individual triggers and jobs
I would create a spring bean with a link to the scheduler or trigger Quartz and a simple boolean isMasterNode to persist the state. Then I expose two calls to the restricted web service, makeMaster and makeSlave, which will call Scheduler.resume () or standby / pause, respectively.
Finall, the big question is how and with what you determine that another node has crashed.
If you are using a hardware loadbalancer to control this, you can configure it to call WSM 'makeMaster' on the new 'primary' node, which in turn calls Scheduler.resume () or similar.
HTH
source to share