假如你讓一個非集群的 Quartz 應用與集群節點並行着運行,設法使用 JobInitializationPlugin和 RAMJobStore
Quartz支持可選節點執行job
quartz集群,會自動將觸發的job均衡的分發到各個節點。不過我現在有一個特殊的job,希望觸發后可以在每個節點(或是指定的節點)執行。
百度、Google 了半天。。。沒找到答案。
后來自己折騰了一天搞定了...
效果 http://www.cnblogs.com/interdrp/p/4063365.html
StdSchedulerFactory,調用其initialize方法,並且自己定義填寫配置內容:
1
2
3
4
5
6
7
8
|
StdSchedulerFactory sf = new StdSchedulerFactory(); Properties props = new Properties(); props.put("org.quartz.scheduler.instanceName", "ReYoQuartzAlone");//必須 props.put("org.quartz.scheduler.instanceId", "AUTO"); props.put("org.quartz.threadPool.class", "org.quartz.simpl.SimpleThreadPool"); props.put("org.quartz.threadPool.threadCount", "10");//必須 props.put("org.quartz.threadPool.threadPriority", "5"); props.put("org.quartz.threadPool.threadsInheritContextClassLoaderOfInitializingThread", "true"); sf.initialize(props); |