Spring quartz/cron jobs in a distributed environment

quartz-schedulerspring

I have a fleet of about 5 servers. I want to run an identical Spring/Tomcat app on each machine.

I also need a particular task to be executed every ten minutes. It should only run on one of the machines. I need some sort of election protocol or other similar solution.

Does Spring or Quartz have any sort of built-in distributed cron solution, or do I need to implement something myself?

Best Answer

Hazelcast has a distributed executor framework which you can use to run jobs using the JDK Executor framework (which, by the way, is possibly more testable than horrid Quartz... maybe). It has a number of modes of operation, including having it pick a single node "at random" to execute your job on.

See the documentation for more details

Related Topic