Quartz.net Summary (iii) Quartz configuration

Source: Internet
Author: User
Tags log4net

The first two articles, has introduced the use of quartz.net and cron expression expressions, today said quartz configuration, quartz related configuration has three quartz.config, Quartz_jobs.xml, Log4net.config. Where Quartz.config is the basic configuration, Quartz_jobs.xml is the associated job task profile, and Log4net.config is the configuration of the log records.

1. Quartz.config, is the quartz.net is the basic configuration, mainly configures the path of Quartz_jobs.xml, and other related parameters. The default Quartz task profile is Quartz_jobs.xml, under the root directory of the Quartz service, can be quartz.plugin.xml.fileNames = ~/quartz_ in Quartz.config Jobs.xml the settings.

# can configure your scheduler in either <quartz> configuration section# or in Quartz properties file# Configura tion section have precedence quartz.scheduler.instanceName = serverscheduler# Configure thread pool Infoquartz.threadpool . Type = Quartz.Simpl.SimpleThreadPool, Quartzquartz.threadPool.threadCount = 10quartz.threadpool.threadpriority = Normal # Job Initialization plugin handles our XML reading, without it defaults is Usedquartz.plugin.xml.type = quartz.pl Ugin. Xml.xmlschedulingdataprocessorplugin, Quartzquartz.plugin.xml.fileNames = ~/quartz_jobs.xml # export this server to Remoting Contextquartz.scheduler.exporter.type = Quartz.Simpl.RemotingSchedulerExporter, Quartzquartz.scheduler.exporter.port = 555quartz.scheduler.exporter.bindname = QuartzSchedulerquartz.scheduler.exporter.channelType = Tcpquartz.scheduler.exporter.channelName = Httpquartz

2. Quartz_jobs.xml, is the associated job task profile. There are mainly jobs and trigger two groups to the node.

<?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> <!--definition job1--> <job> & lt;name>job1</name> <group>JobGroup</group> <description>quartz job1</description&      Gt <job-type>Quartz.Net.Jobs.Job1,Quartz.Net.Jobs</job-type> <durable>true</durable> <re      cover>false</recover> </job> <!--definition job2--> <job> <name>Job2</name> <group>JobGroup</group> <description>quartz job2</description> <job-type>quartz . Net.jobs.job2,quartz.net.jobs</job-type> <durable>true</durable> <recover>false</recover> </job> &L t;!        --Define JOB1 triggers to perform Job1 tasks every 30 seconds--<trigger> <cron> <name>Job1Trigger</name> <group>JobTriggerGroup</group> <job-name>Job1</job-name> &LT;JOB-GROUP&GT;JOBGROUP&L T;/job-group> &LT;CRON-EXPRESSION&GT;0/30 * * * *?</cron-expression> </cron> &LT;/TRIGGER&G    T        <!--define JOB2 triggers to perform Job2 tasks once per minute--<trigger> <cron> <name>Job2Trigger1</name> <group>JobTriggerGroup</group> <job-name>Job2</job-name> &LT;JOB-GROUP&GT;JOBGR Oup</job-group> <cron-expression>0 * * * *?</cron-expression> </cron> </trigger > </schedule></job-scheduling-data>

Job task, This node is used to define each specific task, multiple tasks Please create multiple job nodes.

1. Name of a task, the names of multiple jobs in the same group cannot be the same, such as:<name>job1</name>

2. Group tasks belong to groups that identify the groups to which the task belongs, such as:<group>jobgroup</group>

3. Job-type the specific type of task and its owning assembly, implements the Ijob interface's class name containing the full namespace, the assembly name, such as: <job-type>Quartz.Net.Jobs.Job1,Quartz.Net.Jobs< /job-type>

The rest of the nodes follow the default settings.

Trigger task triggers, which define at what time and in what way the task (job), the same job can define multiple trigger, each trigger their own independent execution schedule, each trigger must define a type of trigger ( Calendar-interval, simple, cron).

Calendar-interval use is relatively small, generally simple and cron, here do not explain.

Simple task trigger, which can dispatch tasks for repetitive execution

1. Name trigger names, names must be different in the same group

2. Group Trigger Groups

3. Job-name the name of the task to be dispatched, the job-name must be exactly the same as the name in the corresponding job node, such as:<job-name>job1</job-name>

4. Job-group scheduling Task (Job) belongs to the group, the value must be exactly the same as the group in the job, such as:<job-group>jobgroup</job-group>

5. Repeat-count task execution times, such as:<repeat-count>-1</repeat-count> for unlimited execution, <repeat-count>10</ Repeat-count> represents 10 executions

6. Repeat-interval task trigger interval in milliseconds, such as:<repeat-interval>10000</repeat-interval> every 10 seconds

Cron complex task triggers, mainly using cron expressions to customize task scheduling, generally used more are cron triggers. For a cron expression, refer to the previous blog, "Quartz.net Summary (ii) Crontrigger and cron expressions."

1. Name trigger names, names must be different in the same group

2. Group Trigger Groups

3. Description Trigger Description

4. Job-name the task name to be dispatched, note that the job-name must be exactly the same as the name in the corresponding job node, such as:<job-name>job1</job-name>

5. Job-group scheduling Task (Job) belongs to the group, the value must be exactly the same as the group in the job, such as:<job-group>jobgroup</job-group>

6. Cron expression for cron-expression task execution, such as: <CRON-EXPRESSION>0/30 * * * *?</cron-expression> every 30 seconds

The rest of the nodes follow the default settings.

According to the actual project needs flexible configuration quartz_jobs.xml, do not need to make additional modifications to other background code, to achieve flexible multi-task scheduling, it is important to note that modified Quartz_ Jobs.xml the file, the Quartz service does not reload the file by default and requires a restart of the service.

3. Log4net.config

(slightly), please refer to other configuration regarding log4net.

Quartz.net Summary (iii) Quartz configuration

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.