zoukankan      html  css  js  c++  java
  • 【quartz】 入门-配置文件

    quartz 启动

     NameValueCollection props = (NameValueCollection)ConfigurationManager.GetSection("quartz");
                //PropertiesParser cfg = new PropertiesParser(props);
                ISchedulerFactory sf = new StdSchedulerFactory(props);
                IScheduler sched = sf.GetScheduler();
                sched.Start();

    app.config 或者 web.config

    <?xml version="1.0" encoding="utf-8" ?>
    <configuration>
      <configSections>
        <section name="quartz" type="System.Configuration.NameValueSectionHandler" />
      </configSections>
    
      <quartz>
        <add key="quartz.scheduler.instanceName" value="ExampleDefaultQuartzScheduler"/>
        <add key="quartz.threadPool.type" value="Quartz.Simpl.SimpleThreadPool, Quartz"/>
        <add key="quartz.threadPool.threadCount" value="10"/>
        <add key="quartz.threadPool.threadPriority" value="2"/>
        <add key="quartz.jobStore.misfireThreshold" value="60000"/>
        <add key="quartz.jobStore.type" value="Quartz.Simpl.RAMJobStore, Quartz"/>
        <!--******************************Plugin配置********************************************* -->
        <add key="quartz.plugin.xml.type" value="Quartz.Plugin.Xml.XMLSchedulingDataProcessorPlugin, Quartz" />
        <add key="quartz.plugin.xml.fileNames" value="~/quartz_jobs.xml"/>
      </quartz>
    </configuration>
    ~/quartz_jobs.xml

    simple和cron两种方式
    <?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>quartzdemo.HelloJob, quartzdemo</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>sampleJob2</name>
          <group>sampleGroup</group>
          <description>Sample job for Quartz Server</description>
          <job-type>quartzdemo.HelloJob2, quartzdemo</job-type>
          <durable>true</durable>
          <recover>false</recover>
        </job>
        <trigger>
          <cron>
            <name>sampleSimpleTrigger2</name>
            <group>sampleSimpleGroup2</group>
            <description>Simple trigger to simply fire sample job</description>
            <job-name>sampleJob2</job-name>
            <job-group>sampleGroup</job-group>
            <cron-expression>0/3 * * * * ?</cron-expression>
          </cron>
        </trigger> 
      </schedule>
    </job-scheduling-data>
  • 相关阅读:
    fail-fast以及Iterator对象
    LeetCode~1351.统计有序矩阵中的负数
    LeetCode~75.颜色分类
    LeetCode~5364. 按既定顺序创建目标数组
    LeetCode~945.使数组唯一的最小增量
    LeetCode~409. 最长回文串
    笔记: SpringBoot + VUE实现数据字典展示功能
    JSON parse error: Cannot deserialize value of type `java.util.Date` from String
    为什么要用location的hash来传递参数?
    初识Git
  • 原文地址:https://www.cnblogs.com/viewcozy/p/4608836.html
Copyright © 2011-2022 走看看