Quartz.NET 2.0 可以很方便的通过配置的xml文件方式实现灵活的任务调度配置(1.0版本就已经支持了,只是配置文件格式有些变化)
默认的quartz任务配置文件为quartz_jobs.xml,在quartz服务的根目录下,可以通过quartz.config中quartz.plugin.xml.fileNames = ~/quartz_jobs.xml进行设置
默认quartz.config文件结构如下
quartz.config
1 # You can configure your scheduler in eitherconfiguration section 2 # or in quartz properties file 3 # Configuration section has precedence 4 5 quartz.scheduler.instanceName = ServerScheduler 6 7 # configure thread pool info 8 quartz.threadPool.type = Quartz.Simpl.SimpleThreadPool, Quartz 9 quartz.threadPool.threadCount = 10 10 quartz.threadPool.threadPriority = Normal 11 12 # job initialization plugin handles our xml reading, without it defaults are used 13 quartz.plugin.xml.type = Quartz.Plugin.Xml.XMLSchedulingDataProcessorPlugin, Quartz 14 quartz.plugin.xml.fileNames = ~/quartz_jobs.xml 15 16 # export this server to remoting context 17 quartz.scheduler.exporter.type = Quartz.Simpl.RemotingSchedulerExporter, Quartz 18 quartz.scheduler.exporter.port = 555 19 quartz.scheduler.exporter.bindName = QuartzScheduler 20 quartz.scheduler.exporter.channelType = tcp 21 quartz.scheduler.exporter.channelName = httpQuartz
首先看一下简单的quartz_jobs.xml示例
quartz_jobs.xml
1 2 3 4 56 7 8 10 11true 912 13 14 21sampleJob 15sampleGroup 16Sample job for Quartz Server 17Quartz.Server.SampleJob, Quartz.Server 18true 19false 2022 33 3423 32sampleSimpleTrigger 24sampleSimpleGroup 25Simple trigger to simply fire sample job 26sampleJob 27sampleGroup 28SmartPolicy 29-1 3010000 3135 42CommissionJob 36CommissionJob 37Sample job for Quartz Server 38Settlement.Jobs.CommissionJob, Settlement.Jobs 39true 40false 4143 44 sampleSimpleTrigger2 45sampleSimpleTrigger2 46sampleJob2