使石英在集群环境中只有一个线程

时间:2016-08-24 12:41:26

标签: cron quartz-scheduler job-scheduling

我有一个带有2个实例和一些cronjobs不时运行的webapp。当只有一个调度程序实例正在运行时,cronjobs会在彼此之后触发,下一个等待第一个完成,并且这正是我希望它如何运行,因为几乎每个cronjob都访问相同的数据。

但是,如果我在第二个实例中启动调度程序,则第二个cronjobs在第一个完成之前启动。

我找到了一些"解决方案"并实施了tehm,但他们没有工作。

my quartz.properties

# Use the MongoDB store
org.quartz.jobStore.class=com.novemberain.quartz.mongodb.MongoDBJobStore
# MongoDB URI (optional if 'org.quartz.jobStore.addresses' is set)
org.quartz.jobStore.mongoUri=
# comma separated list of mongodb hosts/replica set seeds (optional if 'org.quartz.jobStore.mongoUri' is set)
org.quartz.jobStore.addresses=mongodb://localhost:27017
# database name
org.quartz.jobStore.dbName=mytDb
# Will be used to create collections like mycol_jobs, mycol_triggers, mycol_calendars, mycol_locks
org.quartz.jobStore.collectionPrefix=quartz
# thread count setting is ignored by the MongoDB store but Quartz requries it
org.quartz.threadPool.threadCount=1
#set to true to enable the cluster funktions
org.quartz.jobStore.isClustered=true

org.quartz.jobStore.clusterCheckinInterval=20000

org.quartz.scheduler.instanceId=AUTO

如你所见,我有一个1的线程,我认为发生的是当有两个实例运行时有2个线程。

那么如何配置石英,有两个Scheduler实例在运行,但只有一个正在进行工作,第二个是在一个实例崩溃时使用。

我还在我的Job类中添加了@DisallowConcurrentExecution,但这似乎也没有用。

0 个答案:

没有答案
相关问题