The quartz.net of Timing Dispatch series

Source: Internet
Author: User

Source: https://www.cnblogs.com/yaopengfei/p/9216229.html

I. BACKGROUND

We in the daily development, you may encounter such a demand: "3rd per month to send users messages, remind users xxx", "0 points per day need to count the time before the time of attendance record", "1th per month to calculate the inventory situation last month", "timed initialization data for other business use", " Every 2 minutes round the inquiries database to see if a business is audited, and prompts the user "and so on."

The above requirements in the development are very common, but they are only a low-end demand, slightly higher demand, such as: "Customer service sent to dispatch, if the dispatch of 3 days did not perform any operation, need to prompt dispatch to hurry to send a car", to this step so far looks and the above demand is no different, but if I ask, Can the system administrator dynamically configure the prompt time? That is, the administrator can configure the schedule for a few days without performing any action, the system needs to give hints. This change, for some novice only, the difficulty has risen steeply.

Below we continue to upgrade requirements, the system has a, B, C, D .... And so on multiple businesses, the system administrator can dynamically configure the execution time of each business (such as: every 2s execution, monthly execution of 3rd), and can dynamically control the opening, closing, pausing, all shut down, all pause and so on each business. The need to upgrade to this extent, the novice is estimated to catch shrimp, some experienced people but have not contacted the similar framework, faced with such needs, also need a little time to study.

Doubts:

Requirement 1: That is, we often say that the timing of tasks, Jane answer can be achieved by the use of the timer class, the need for time complex needs to rely on third-party framework to achieve, such as: Quartz.net.

Requirement 2: We need to dynamically configure the timing task execution time.

Requirement 3: We need to set up a scheduling framework, and then dynamically configure the task's opening, closing, and trigger scenarios.

Demand three is our ultimate goal, that is, we want to build a common schedule scheduling framework, you can manually increase the timing tasks, configure their triggers, manually control the opening and closing of tasks (b/S architecture), or the C/s architecture, eventually deployed in the form of Windows services.

In summary: Quartz.net will be our best choice.

Two. Quartz.net Introduction

1. Quartz.net is a powerful, open-source, lightweight job scheduling framework that is a. Net migration of the Opensymphony Quartz API, which is rewritten in C # and can be used in WinForm and ASP. It is flexible and not complex. You can use it to create simple or complex job schedules for executing a job.

It has several major advantages:

A. Persistent database: SQL Server, MySQL, MongoDB, Redis

B. Cluster support: Dual-machine hot standby

C. Support Web b/S architecture and WinForm/C/S architecture

D.trigger can flexibly control the time of all kinds of demanding time requirements

2. Use of the Quartz.net framework

①. Introduction Method:

A. Introducing a search quartz through NuGet introduces the appropriate assembly.

(2.x version needs to introduce three assemblies: Common.logging, Common.Logging.Core, quartz, and an XSD file (for code hints for XML configuration)

B. Go to the official website to download the source code, through the introduction of the use of source code (http://www.quartz-scheduler.net/).

  PS: Currently the latest version is 3.0.5 (2018-06-23), the 2.6.1 is the last version of the 2x, 3x support. Netcore, and some changes in basic usage, it's best to use vs2017

②. Basic use:

A. Creating a job schedule Pool (Scheduler)

B. Create a specific job as job (specific job needs to be performed separately in one file)

C. Create and configure a trigger that is trigger

D. Adding jobs and trigger to the job scheduling pool

E. Starting the dispatch start

3. Official address

Official website: http://www.quartz-scheduler.net/

Example: http://www.quartz-scheduler.net/documentation/quartz-2.x/quick-start.html

Three. Series Chapters

Below we will together through the following several chapters, the system to learn the basic usage of quartz.net, extend some advanced configuration, and finally from the framework of the perspective of the timing scheduling this kind of common problems, welcome to the broad masses of Bo friends come to exchange, correction, learning.

The first section: the review of timer tasks, the introduction of Quartz.net, the embodiment of AOP thought:

section II: Compare datetime and DateTimeOffset two time types and introduce several types of time forms used in quartz.net (fixed point, rounding, multiple, increment)     

Section III: Scheduler (creation, encapsulation, basic method) and job (creation, association, etc.) of the quartz.net five components:

Fourth: Trigger general usage of quartz.net five components (common method, priority, job Association, etc.):

The fifth section: Quartz.net five major components of the trigger four trigger class:

Section sixth: Class six calander processing six different time scenes:

Section Seventh: Trigger (Simpletrigger, Crontrigger) misfiring (misfire) policy:

The eighth section: the Simplethreadpool of quartz.net five components and its four configuration schemes:

Nineth: Using Remotesheduler to achieve scheduler cross-server remote control:

Tenth: Using SQL Server to achieve quartz persistence and dual-machine hot-standby cluster mode:

11th: Encapsulation of the general scheduling framework, the implementation of new, delete, open, pause Scheduled tasks (not finished):

Section 12th: Summarize quartz.net several deployment modes (IIS, EXE, service Deployment "with Topself, Service class"):

Timing Scheduling Series Quartz.net detailed (Turn)

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.