Quartz.net is an open-source job scheduling framework, which is a. Net migration of the Opensymphony Quartz API, written in C # that can be used in WinForm and ASP. It provides a great deal of flexibility without sacrificing simplicity. You can use it to create simple or complex schedules for executing a job. It has many features, such as database support, clustering, plugins, support for cron-like expressions, and so on.
Quick Start
1. Project website: http://www.quartz-scheduler.net/
2, recommended official website Download compressed package, browse the source of the approximate (inside source code, use example), Src/quartz can be introduced into their own projects, quartz.net framework needs a third-party library, the introduction of these three-party library is required
NuGet mode:
Install-package Quartz
3. Using the configuration file
1) AppConfig or Webconfig
<configSections>
<section name= "Quartz" type= "System.configuration.namevaluesectionhandler,system, version=4.0.0.0, Culture= Neutral, publickeytoken=b77a5c561934e089 "/>
</configSections>
<quartz>
<add key= "Quartz.scheduler.instanceName" value= "MyServer"/>
<add key= "Quartz.scheduler.instanceId" value= "MyServer"/>
<add key= "Quartz.threadPool.type" value= "Quartz.Simpl.SimpleThreadPool, quartz"/>
<add key= "Quartz.threadPool.threadCount" value= "/>"
<add key= "quartz.threadPool.threadPriority" value= "Normal"/>
<add key= "Quartz.plugin.xml.type" value= "Quartz.Plugin.Xml.XMLSchedulingDataProcessorPlugin, quartz"/>
<add key= "Quartz.plugin.xml.fileNames" value= "~/quartz_jobs.xml"/>
<add key= "Quartz.jobStore.useProperties" value= "true"/>
<add key= "quartz.jobStore.clustered" value= "false"/>
<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.MySQLDelegate, quartz"/>
<add key= "Quartz.jobStore.dataSource" value= "Default"/>
<add key= "quartz.dataSource.default.connectionString" value= "server=.; Database=.; User id=.; password=. " />
<add key= "Quartz.dataSource.default.provider" value= "MySql-67"/>
<add key= "Quartz.scheduler.exporter.type" value= "Quartz.Simpl.RemotingSchedulerExporter, quartz"/>
<add key= "Quartz.scheduler.exporter.port" value= "555"/>
<add key= "Quartz.scheduler.exporter.bindName" value= "Myappserver"/>
<add key= "Quartz.scheduler.exporter.channelType" value= "tcp"/>
</quartz>
2) Jobs.xml
<Job-scheduling-dataxmlns= "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> </Schedule> </Job-scheduling-data>
Name (required), the names of multiple jobs in the same group cannot be the same, and if group is not set, all job without group is the same group, such as:<name>samplejob</name>
Group (optional) tasks belong to groups that identify the groups to which the task belongs, such as:<group>samplegroup</group>
Description (optional) task description, which describes the specific contents of the task, such as: <description>sample job for Quartz server</description>
Job-type (required) task type, the specific type of task and its owning assembly, format: the class name that implements the Ijob interface that contains the full namespace, the assembly name, such as: <job-type>quartz.server.samplejob, Quartz.server</job-type>
Durable (optional) The specific function is not known, the official example defaults to true, such as:<durable>true</durable>
Recover (optional) The specific role is not known, the official example defaults to false, such as:<recover>false</recover>
Trigger task triggers, which define the way a job is used, the same job can define multiple trigger, and multiple trigger perform schedules independently of each other, and each trigger must define only one type of trigger ( Calendar-interval, simple, cron)
Calendar-interval a type of trigger, used less, is skipped here
Simple task trigger, which can dispatch tasks for repetitive execution
Name (required) trigger names, names must be different in the same group
Group (optional) Trigger groups
Description (optional) trigger description
Job-name (required) The task name to be dispatched, the job-name must be exactly the same as the name in the corresponding job node
Job-group (optional) the group to which the dispatch task (Job) belongs, which must be exactly the same as the group in the job
Start-time (optional) task start execution time UTC time, Beijing time needs +08:00, such as:<start-time>2012-04-01t08:00:00+08:00</start-time> Beijing time April 1, 2012 8:00 start execution, note that this property will be detected when the service starts or restarts, if this property is not set or the Start-time setting is earlier than the current time, the service starts immediately after the start of the schedule, if the time is set later than the current time, The service will wait for the same set time before the task is executed for the first time, generally do not set this property if there is no special need
Repeat-count (required) The number of task executions, such as:<repeat-count>-1</repeat-count> for unlimited execution, <repeat-count>10</ Repeat-count> represents 10 executions
Repeat-interval (required) task trigger interval (milliseconds), such as:<repeat-interval>10000</repeat-interval> executed every 10 seconds
Cron Complex task trigger-customizing task scheduling with Cron expressions (highly recommended)
Name (required) trigger names, names must be different in the same group
Group (optional) Trigger groups
Description (optional) trigger description
Job-name (required) The task name to be dispatched, the job-name must be exactly the same as the name in the corresponding job node
Job-group (optional) the group to which the dispatch task (Job) belongs, which must be exactly the same as the group in the job
Start-time (optional) task start execution time UTC time, Beijing time needs +08:00, such as:<start-time>2012-04-01t08:00:00+08:00</start-time> Indicates that the property will be detected when the service starts or restarts on April 1, 2012 8:00, and if this property is not set, the service performs a task schedule based on the Cron-expression settings, and if the Start-time is set earlier than the current time, After the service starts, it ignores the cron-expression setting, executes the dispatch immediately, and then executes the task schedule according to Cron-expression, and if the set time is later than the current time, the service will be applied after the same setting time is reached Cron-expression , perform task scheduling according to the rules, do not set this property if there is no special need
Cron-expression (required) cron expression, such as: <CRON-EXPRESSION>0/10 * * * * *?</cron-expression> every 10 seconds
Quartz mainly consists of three cores: Scheduler (IScheduler), Task (Jobdetail), Trigger (Trigger).
Information:
Quartz.net Official 2.X Tutorial http://www.quartz-scheduler.net/documentation/quartz-2.x/tutorial/index.html
Quartz.net Open Source Address https://github.com/quartznet/quartznet
Blogs:
Many, no longer repeat ...
Quartz.net Open Source Job scheduling schema