问题
I am using Quartz scheduler with MySql as JobStore in a maven based application and I want to implement the clustering feature of Quartz but I don't have any idea how to add multiple nodes in the cluster and how Quartz knows about the nodes and manages them?
In short I want to understand How Quartz actually works and how to setup clustering environment.
Any help will be highly appreciated.
Thanks
回答1:
How Quartz actually works
You have to configure Quartz (quartz.properties) in all your cluster nodes. Quartz will recognize and use this config file provided it is somewhere in the classpath. The configuration file must be identical (except a few exceptions) on all the nodes, and contain:
- the property org.quartz.jobStore.isClustered = true
- a JDBC JobStore config, cf http://quartz-scheduler.org/documentation/quartz-2.1.x/configuration/ConfigJobStoreTX
The 2nd point is important because it connects Quartz to a database where the information about the jobs will be stored and shared in your cluster nodes. For example, every time a job is fired on a node, the information is passed to the other nodes via the database, and other nodes won't fire the same job again.
How to setup clustering environment
You need a working cluster of your App Server before. Make sure your AS (tomcat, jboss, etc) is properly configured in a cluster, then configure Quartz on each node as explained above. Details are in the link provided by Ashish.
来源:https://stackoverflow.com/questions/19557173/how-to-configure-clustering-with-more-than-one-node-in-quartz-scheduler