quartz 2.0 與1.0功能對比

平常開發來講,相對於1.0版,2.0版在使用上有如下幾點須要注意的變化express

變化一 比1.0多引用了C5.dlltcp

  • C5.dll 一個C#和其餘CLI語言的泛型集合類。.Net2.0及以上才能夠使用。簡介地址:http://www.itu.dk/research/c5/

變化二 quartz.config有細微變化this

  • 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
    複製代碼

    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.JobInitializationPlugin, 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
    複製代碼
  • 2.0 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
    複製代碼

     

變化三 實現IJob接口 JobExecutionContext對象變成了IJobExecutionContext spa

  • 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配置節發生了變化.net

  • 根結點有<quartz>變爲了<job-scheduling-data>
  • 新增了<schedule>節點,<job>均放在<schedule>節點下,刪除了 <job-detail>節點,同時刪除了<volatile>false</volatile>屬性
  • <trigger>不在放置在<job>下面,改成和<job>平行
  • 1.0 quartz_jobs.xml示例
    複製代碼

    1 <?xml version="1.0" encoding="UTF-8"?> 2 <quartz xmlns="http://quartznet.sourceforge.net/JobSchedulingData" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.0" overwrite-existing-jobs="true"> 3 4 <job> 5 <job-detail> 6 <name>sampleJob</name> 7 <group>sampleGroup</group> 8 <description>Sample job for Quartz Server</description> 9 <job-type>Quartz.Job.NoOpJob, Quartz</job-type> 10 <volatile>false</volatile> 11 <durable>true</durable> 12 <recover>false</recover> 13 </job-detail> 14 <trigger> 15 <simple> 16 <name>sampleSimpleTrigger</name> 17 <group>sampleSimpleGroup</group> 18 <description>Simple trigger to simply fire sample job</description> 19 <misfire-instruction>SmartPolicy</misfire-instruction> 20 <volatile>false</volatile> 21 <job-name>sampleJob</job-name> 22 <job-group>sampleGroup</job-group> 23 <repeat-count>RepeatIndefinitely</repeat-count> 24 <repeat-interval>3000</repeat-interval> 25 </simple> 26 </trigger> 27 </job> 28 29 <job> 30 <job-detail> 31 <name>sampleJob2</name> 32 <group>sampleGroup2</group> 33 <description>Sample job for Quartz Server</description> 34 <job-type>Quartz.Job.NoOpJob, Quartz</job-type> 35 <volatile>false</volatile> 36 <durable>true</durable> 37 <recover>false</recover> 38 </job-detail> 39 <trigger> 40 <cron> 41 <name>sampleSimpleTrigger2</name> 42 <group>sampleSimpleTrigger2</group> 43 <job-name>sampleJob2</job-name> 44 <job-group>sampleGroup2</job-group> 45 <cron-expression>0/10 * * * * ?</cron-expression> 46 </cron> 47 </trigger> 48 </job> 49 </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版本不一樣code

  • Quartz 1.0能夠支持.Net 1.1 和 .Net 2.0及以上版本
  • Quartz 2.0僅支持.Net 3.5及以上版本,放棄了對.Net 1.1和.Net 2.0的支持
相關文章
相關標籤/搜索