标签:des style blog http color 使用
Quartz.NET 2.0 可以很方便的通过配置的xml文件方式实现灵活的任务调度配置(1.0版本就已经支持了,只是配置文件格式有些变化)
默认的quartz任务配置文件为quartz_jobs.xml,在quartz服务的根目录下,可以通过quartz.config中quartz.plugin.xml.fileNames = ~/quartz_jobs.xml进行设置
默认quartz.config文件结构如下
1 # You can configure your scheduler in either <quartz> configuration 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示例
1 <?xml version="1.0" encoding="UTF-8"?>
2
3 <!-- This file contains job definitions in schema version 2.0 format -->
4
5 <job-scheduling-data xmlns="http://quartznet.sourceforge.net/JobSchedulingData" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.0">
6
7 <processing-directives>
8 <overwrite-existing-data>true</overwrite-existing-data>
9 </processing-directives>
10
11 <schedule>
12
13 <job>
14 <name>sampleJob</name>
15 <group>sampleGroup</group>
16 <description>Sample job for Quartz Server</description>
17 <job-type>Quartz.Server.SampleJob, Quartz.Server</job-type>
18 <durable>true</durable>
19 <recover>false</recover>
20 </job>
21 <trigger>
22 <simple>
23 <name>sampleSimpleTrigger</name>
24 <group>sampleSimpleGroup</group>
25 <description>Simple trigger to simply fire sample job</description>
26 <job-name>sampleJob</job-name>
27 <job-group>sampleGroup</job-group>
28 <misfire-instruction>SmartPolicy</misfire-instruction>
29 <repeat-count>-1</repeat-count>
30 <repeat-interval>10000</repeat-interval>
31 </simple>
32 </trigger>
33
34 <job>
35 <name>CommissionJob</name>
36 <group>CommissionJob</group>
37 <description>Sample job for Quartz Server</description>
38 <job-type>Settlement.Jobs.CommissionJob, Settlement.Jobs</job-type>
39 <durable>true</durable>
40 <recover>false</recover>
41 </job>
42 <trigger>
43 <cron>
44 <name>sampleSimpleTrigger2</name>
45 <group>sampleSimpleTrigger2</group>
46 <job-name>sampleJob2</job-name>
47 <job-group