Quartz.NET 2.0 2012年4月9日发布了Released
Quartz.NET 项目地址 http://quartznet.sourceforge.net/
Quartz.NET 2.0 学习笔记(1) :Quartz.NET简介
Quartz.NET 2.0 学习笔记(2) :和1.0的几点不同
Quartz.NET 2.0 学习笔记(3) :通过配置文件实现任务调度
Quartz.NET 2.0 学习笔记(4) :cron表达式
Quartz.NET 2.0 学习笔记(5) :实例创建Windows服务实现任务调度
日常开发来说,相对于1.0版,2.0版在使用上有以下几点需要注意的变化
变化一 比1.0多引用了C5.dll
- C5.dll 一个C#和其他CLI语言的泛型集合类。.Net2.0及以上才可以使用。简介地址:http://www.itu.dk/research/c5/
变化二 quartz.config有细微变化
- quartz.plugin.xml.type由1.x的Quartz.Plugin.Xml.JobInitializationPlugin, Quartz变为了2.0中的Quartz.Plugin.Xml.XMLSchedulingDataProcessorPlugin, Quartz
- 2.0版本新增了一行配置quartz.scheduler.exporter.channelName = httpQuart
- 1.0 quartz.config
# You can configure your scheduler in either <quartz> configuration section # or in quartz properties file # Configuration section has precedence quartz.scheduler.instanceName = ServerScheduler # configure thread pool info quartz.threadPool.type = Quartz.Simpl.SimpleThreadPool, Quartz quartz.threadPool.threadCount = 10 quartz.threadPool.threadPriority = Normal # job initialization plugin handles our xml reading, without it defaults are used --> quartz.plugin.xml.type = Quartz.Plugin.Xml.JobInitializationPlugin, Quartz quartz.plugin.xml.fileNames = ~/quartz_jobs.xml # export this server to remoting context quartz.scheduler.exporter.type = Quartz.Simpl.RemotingSchedulerExporter, Quartz quartz.scheduler.exporter.port = 555 quartz.scheduler.exporter.bindName = QuartzScheduler quartz.scheduler.exporter.channelType = tcp
- 2.0 quartz.config
# You can configure your scheduler in either <quartz> configuration section # or in quartz properties file # Configuration section has precedence quartz.scheduler.instanceName = ServerScheduler # configure thread pool info quartz.threadPool.type = Quartz.Simpl.SimpleThreadPool, Quartz quartz.threadPool.threadCount = 10 quartz.threadPool.threadPriority = Normal # job initialization plugin handles our xml reading, without it defaults are used quartz.plugin.xml.type = Quartz.Plugin.Xml.XMLSchedulingDataProcessorPlugin, Quartz quartz.plugin.xml.fileNames = ~/quartz_jobs.xml # export this server to remoting context quartz.scheduler.exporter.type = Quartz.Simpl.RemotingSchedulerExporter, Quartz quartz.scheduler.exporter.port = 555 quartz.scheduler.exporter.bindName = QuartzScheduler quartz.scheduler.exporter.channelType = tcp quartz.scheduler.exporter.channelName = httpQuartz
变化三 实现IJob接口 JobExecutionContext对象变成了IJobExecutionContext
- 1.0 IJob接口
public class SimpleJob : IJob { #region IJob 成员 public void Execute(JobExecutionContext context) { throw new NotImplementedException(); } #endregion }
- 2.0 IJob接口
public class SimpleJob : IJob { #region IJob 成员 public void Execute(IJobExecutionContext context) { throw new NotImplementedException(); } #endregion }
变化四 quartz_jobs.xml配置节发生了变化
- 根结点有<quartz>变为了<job-scheduling-data>
- 新增了<schedule>节点,<job>均放在<schedule>节点下,删除了 <job-detail>节点,同时删除了<volatile>false</volatile>属性
- <trigger>不在放置在<job>下面,改为和<job>平行
- 1.0 quartz_jobs.xml示例
<?xml version="1.0" encoding="UTF-8"?> <quartz xmlns="http://quartznet.sourceforge.net/JobSchedulingData" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.0" overwrite-existing-jobs="true"> <job> <job-detail> <name>sampleJob</name> <group>sampleGroup</group> <description>Sample job for Quartz Server</description> <job-type>Quartz.Job.NoOpJob, Quartz</job-type> <volatile>false</volatile> <durable>true</durable> <recover>false</recover> </job-detail> <trigger> <simple> <name>sampleSimpleTrigger</name> <group>sampleSimpleGroup</group> <description>Simple trigger to simply fire sample job</description> <misfire-instruction>SmartPolicy</misfire-instruction> <volatile>false</volatile> <job-name>sampleJob</job-name> <job-group>sampleGroup</job-group> <repeat-count>RepeatIndefinitely</repeat-count> <repeat-interval>3000</repeat-interval> </simple> </trigger> </job> <job> <job-detail> <name>sampleJob2</name> <group>sampleGroup2</group> <description>Sample job for Quartz Server</description> <job-type>Quartz.Job.NoOpJob, Quartz</job-type> <volatile>false</volatile> <durable>true</durable> <recover>false</recover> </job-detail> <trigger> <cron> <name>sampleSimpleTrigger2</name> <group>sampleSimpleTrigger2</group> <job-name>sampleJob2</job-name> <job-group>sampleGroup2</job-group> <cron-expression>0/10 * * * * ?</cron-expression> </cron> </trigger> </job> </quartz>
- 2.0 quartz_jobs.xml示例
<?xml version="1.0" encoding="UTF-8"?> <!-- This file contains job definitions in schema version 2.0 format --> <job-scheduling-data xmlns="http://quartznet.sourceforge.net/JobSchedulingData" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.0"> <processing-directives> <overwrite-existing-data>true</overwrite-existing-data> </processing-directives> <schedule> <job> <name>sampleJob</name> <group>sampleGroup</group> <description>Sample job for Quartz Server</description> <job-type>Quartz.Server.SampleJob, Quartz.Server</job-type> <durable>true</durable> <recover>false</recover> </job> <trigger> <simple> <name>sampleSimpleTrigger</name> <group>sampleSimpleGroup</group> <description>Simple trigger to simply fire sample job</description> <job-name>sampleJob</job-name> <job-group>sampleGroup</job-group> <misfire-instruction>SmartPolicy</misfire-instruction> <repeat-count>-1</repeat-count> <repeat-interval>10000</repeat-interval> </simple> </trigger> <job> <name>CommissionJob</name> <group>CommissionJob</group> <description>Sample job for Quartz Server</description> <job-type>Settlement.Jobs.CommissionJob, Settlement.Jobs</job-type> <durable>true</durable> <recover>false</recover> </job> <trigger> <cron> <name>sampleSimpleTrigger2</name> <group>sampleSimpleTrigger2</group> <job-name>sampleJob2</job-name> <job-group>sampleGroup2</job-group> <cron-expression>0/10 * * * * ?</cron-expression> </cron> </trigger> </schedule> </job-scheduling-data>
变化五 支持.Net版本不同
- Quartz 1.0可以支持.Net 1.1 和 .Net 2.0及以上版本
- Quartz 2.0仅支持.Net 3.5及以上版本,放弃了对.Net 1.1和.Net 2.0的支持
注:此文章属懒惰的肥兔原创,版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接
若您觉得这篇文章还不错请点击下右下角的推荐,有了您的支持才能激发作者更大的写作热情,非常感谢。
如有问题,可以通过lzrabbit@126.com联系我。