I have 4 servers and JVM installed on it. I wrote a java service that Quartz calls these services every 10 minutes. But on 4 servers 4 calls are made every 10 minutes. This silicon creates race conditions. I want only one service on 4 JVMs.
How can I do this using Spring Framework?
In fact, it is quite easy to configure using quartz. Spring alone cannot help you because it does not know about other running JVMs. Quartz, on the other hand, has the concept of a cluster scheduler.
, 4 JVM. 4 . , .
- Quartz ( http://www.opensymphony.com/quartz/wikidocs/ConfigJDBCJobStoreClustering.html), . Spring, .
#============================================================================ # Configure Main Scheduler Properties #============================================================================ org.quartz.scheduler.instanceName = MyClusteredScheduler org.quartz.scheduler.instanceId = AUTO #============================================================================ # Configure ThreadPool #============================================================================ org.quartz.threadPool.class = org.quartz.simpl.SimpleThreadPool org.quartz.threadPool.threadCount = 25 org.quartz.threadPool.threadPriority = 5 #============================================================================ # Configure JobStore #============================================================================ org.quartz.jobStore.misfireThreshold = 60000 org.quartz.jobStore.class = org.quartz.impl.jdbcjobstore.JobStoreTX org.quartz.jobStore.driverDelegateClass = org.quartz.impl.jdbcjobstore.oracle.OracleDelegate org.quartz.jobStore.useProperties = false org.quartz.jobStore.dataSource = myDS org.quartz.jobStore.tablePrefix = QRTZ_ org.quartz.jobStore.isClustered = true org.quartz.jobStore.clusterCheckinInterval = 20000 #============================================================================ # Configure Datasources #============================================================================ org.quartz.dataSource.myDS.driver = oracle.jdbc.driver.OracleDriver org.quartz.dataSource.myDS.URL = jdbc:oracle:thin:@polarbear:1521:dev org.quartz.dataSource.myDS.user = quartz org.quartz.dataSource.myDS.password = quartz org.quartz.dataSource.myDS.maxConnections = 5 org.quartz.dataSource.myDS.validationQuery=select 0 from dual
, , : 4 , Quartz , , 10 , cron . 10 4 , , .
Spring. , Quartz , . , , , .
, opensymphony.com .
-, , , ( memcached, , ) , . , ( finally).
finally
, , , , , .