1. Job的存储与持久化
Quartz的JobStore接口定义了作业Job、触发器trigger、调度器Scheduler等数据存储机制。Quartz主要有两种Job存储类型:内存存储RAMJobStore和持久化存储JDBCJobStore。下面将对其一一介绍。
2. RAMJobStore
RAMJobStore是将Quartz涉及到的Job、Trigger、Scheduler等信息存储在内存中,是Quartz默认使用且最有效的Job存储方式。但其缺点也显而易见,一旦Quartz程序停止,内存中的Job信息将会丢失。
使用RamJobStore时,如果未设置Quartz的配置文件quartz.properties,则编写Quartz程序默认使用RAMJobStore,如果需要在quartz.properties中进行设置"org.quartz.jobStore.class = org.quartz.simpl.RAMJobStore",可参考如下:
#============================================================================ # Configure Main Scheduler Properties #============================================================================ org.quartz.scheduler.instanceName: TestScheduler org.quartz.scheduler.instanceId: AUTO org.quartz.scheduler.skipUpdateCheck: true #============================================================================ # Configure ThreadPool #============================================================================ org.quartz.threadPool.class: org.quartz.simpl.SimpleThreadPool org.quartz.threadPool.threadCount: 3 org.quartz.threadPool.threadPriority: 5 #============================================================================ # Configure JobStore #============================================================================ org.quartz.jobStore.misfireThreshold: 60000 org.quartz.jobStore.class: org.quartz.simpl.RAMJobStore #============================================================================ # Configure Plugins #============================================================================ org.quartz.plugin.triggHistory.class: org.quartz.plugins.history.LoggingJobHistoryPlugin org.quartz.plugin.jobInitializer.class: org.quartz.plugins.xml.XMLSchedulingDataProcessorPlugin org.quartz.plugin.jobInitializer.fileNames: quartz_data.xml org.quartz.plugin.jobInitializer.failOnFileNotFound: true org.quartz.plugin.jobInitializer.scanInterval: 120 org.quartz.plugin.jobInitializer.wrapInUserTransaction: false