Fork me on GitHub

配置Quartz.net Cluster以及远程管理

这个例子我们介绍的是使用SQL ServerQuartz.net (version 2.0.2) cluster和crystal-quartz 实现远程管理

我们需要一个SQLServer数据库,Quartz.net 将所有的job details 和triggers 保存到这个数据库,使用Quartz.NET提供的数据库脚本Quartz.net database schema creation script.

image

下面我使用crystal-quartz,用它的CrystalQuartz.Example.RemoteScheduler.Server 示例,下面是它的配置

<?xml version="1.0"?>
<configuration>
  <configSections>
    <section name="quartz" type="System.Configuration.NameValueSectionHandler, System, Version=1.0.5000.0,Culture=neutral, PublicKeyToken=b77a5c561934e089" />
    <sectionGroup name="common">
      <section name="logging" type="Common.Logging.ConfigurationSectionHandler, Common.Logging"/>
    </sectionGroup>
  </configSections>
  <common>
    <logging>
      <factoryAdapter type="Common.Logging.Simple.TraceLoggerFactoryAdapter, Common.Logging">
        <arg key="showLogName" value="true"/>
        <arg key="showDataTime" value="true"/>
        <arg key="level" value="INFO"/>
        <arg key="dateTimeFormat" value="HH:mm:ss:fff"/>
      </factoryAdapter>
    </logging>
  </common>
  <quartz>
    <add key="quartz.scheduler.instanceName" value="MyScheduler" />
    <add key="quartz.scheduler.instanceId" value="AUTO" />
    <add key="quartz.threadPool.type" value="Quartz.Simpl.SimpleThreadPool, Quartz" />
    <add key="quartz.threadPool.threadCount" value="5" />
    <add key="quartz.threadPool.threadPriority" value="Normal" />
    <add key="quartz.jobStore.useProperties" value="true" />
    <add key="quartz.jobStore.clustered" value="true" />
    <add key="quartz.jobStore.misfireThreshold" value="60000" />
    <add key="quartz.jobStore.type" value="Quartz.Impl.AdoJobStore.JobStoreTX, Quartz" />
    <add key="quartz.jobStore.tablePrefix" value="QRTZ_" />
    <add key="quartz.jobStore.driverDelegateType" value="Quartz.Impl.AdoJobStore.SqlServerDelegate, Quartz" />
    <add key="quartz.jobStore.dataSource" value="myDS" />
    <add key="quartz.dataSource.myDS.connectionString" value="data source=MONOMATRIX\SQLEXPRESS;initial catalog=quartznet;user id=sa;password=*****;multipleactiveresultsets=True;" />
    <add key="quartz.dataSource.myDS.provider" value="SqlServer-20" />

    <add key="quartz.scheduler.exporter.type" value="Quartz.Simpl.RemotingSchedulerExporter, Quartz"/>
    <add key="quartz.scheduler.exporter.port" value="5555"/>
    <add key="quartz.scheduler.exporter.bindName" value="QuartzScheduler"/>
    <add key="quartz.scheduler.exporter.channelType" value="tcp"/>
  </quartz>
  <startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
  </startup>
</configuration>

 

部署一个管理端,具体可以参照 https://github.com/geffzhang/crystal-quartz/tree/master/examples/CrystalQuartz.Examples.RemoteScheduler/CrystalQuartz.Example.RemoteScheduler ,下面是配置,连接到 5555端口进行远程管理:

<configuration>
    <configSections>
        <sectionGroup name="crystalQuartz" type="CrystalQuartz.Web.Configuration.CrystalQuartzConfigurationGroup">
            <section name="provider" type="CrystalQuartz.Web.Configuration.ProviderSectionHandler" requirePermission="false" allowDefinition="Everywhere"/>
        </sectionGroup>
    </configSections>
    <crystalQuartz>
        <provider>
            <add property="Type" value="CrystalQuartz.Core.SchedulerProviders.RemoteSchedulerProvider, CrystalQuartz.Core"/>
            <add property="SchedulerHost" value="tcp://localhost:5555/QuartzScheduler"/>
        </provider>
        <!--    <provider>-->
        <!--      <add property="Type" value="CrystalQuartz.Spring.SpringSchedulerProvider, CrystalQuartz.Spring" />-->
        <!--      <add property="SchedulerName" value="scheduler" />-->
        <!--    </provider>-->
    </crystalQuartz>
    <appSettings/>
    <connectionStrings/>
    <system.web>        
        <httpHandlers>
            <add verb="*" path="CrystalQuartzPanel.axd" type="CrystalQuartz.Web.PagesHandler, CrystalQuartz.Web" validate="false"/>
        </httpHandlers>
        <pages controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID"/></system.web>
    <!-- 
        The system.webServer section is required for running ASP.NET AJAX under Internet
        Information Services 7.0.  It is not necessary for previous version of IIS.
    -->
    <system.webServer>
        <validation validateIntegratedModeConfiguration="false"/>
    <handlers>
      <add verb="*" name="CrystalQuartzPanel" path="CrystalQuartzPanel.axd" type="CrystalQuartz.Web.PagesHandler, CrystalQuartz.Web" />
    </handlers>
    </system.webServer>
运行一下就可以看到结果了,这里有一个示例http://monomatrix.cloudapp.net/RemoteScheduler/CrystalQuartzPanel.axd?page=job&job=localJob&group=default
image
 

Quartz.NET的管理工具

Quartz.net官方开发指南 第十一课: 高级(企业级)属性

spring&quartz的项目应用总结

http://geekswithblogs.net/TarunArora/category/13586.aspx

MongoDB provider for Quartz.NET

posted @ 2012-12-29 14:18  张善友  阅读(14513)  评论(23编辑  收藏  举报