最近有个项目,用到了tomcat集群。
有需求,让quartz定时任务在某台服务器上不跑。于是一番搜索加询问,终于找到了解决方案。
quartz.properties 实现让一个quartz实例不执行。
# add org.quartz.threadExecutor.class
org.quartz.threadExecutor.class = com.xxx.job.service.impl.DryRunThreadExcutor
#org.quartz.threadPool.class = org.quartz.simpl.SimpleThreadPool
org.quartz.threadPool.class = com.xxx.job.service.impl.MyZeroSizeThreadPool
#org.quartz.threadPool.threadCount = 10
org.quartz.threadPool.threadCount = 0
#org.quartz.threadPool.threadPriority = 5
#org.quartz.threadPool.threadsInheritContextClassLoaderOfInitializingThread = true
参考文档:http://ju.outofmemory.cn/entry/203356