170412. Spring Boot Quartz Introduction

Source: Internet
Author: User

(1) What is quartz?

(2) Characteristics of quartz;

(3) Quartz special Vocabulary description;

(4) The basic realization principle of quartz task scheduling;

Next look at the specific content:

(1) What is quartz?

Quartz is an open-source job scheduling framework written entirely by Java, providing a simple yet powerful mechanism for job scheduling in Java applications. Quartz allows developers to schedule jobs based on time intervals. It implements a many-to-many relationship between jobs and triggers, and can also associate multiple jobs with different triggers. Simply create a Java class with a Org.quarz.Job interface.

(2) Characteristics of quartz;

As an excellent open-source scheduling framework, Quartz has the following features:

① powerful scheduling functions, such as supporting a wide range of scheduling methods, can meet a variety of conventional and special needs;

② flexible application methods, such as support tasks and scheduling of a variety of combinations, support scheduling data storage methods;

③ distributed and cluster capabilities, Terracotta acquisition after the original function on the basis of a further improvement.

The ④quartz is easy to integrate with Spring to enable flexible and configurable scheduling capabilities.

(3) Quartz special Vocabulary description;

Here are some of the special terms used in this article, which declares:

Scheduler :

Task Scheduler

Trigger :

triggers, which define task scheduling time rules

Job :

Tasks, which are scheduled tasks

Misfire :

A task scheduled to be executed but not actually executed.

(4) The basic realization principle of quartz task scheduling;

The core element of quartz task scheduling is scheduler, trigger and job, where trigger and job are the metadata of task scheduling, scheduler is the controller that actually executes the dispatch.

In Quartz, trigger is the element used to define the scheduling time, which is the time rule to perform the task. There are four types of Trigger:simpletrigger,crontirgger,dateintervaltrigger, and Nthincludeddaytrigger, which are mainly available in Quartz. These four types of trigger can meet most of the needs of enterprise applications.

In Quartz, the job is used to represent the task being dispatched. There are two main types of job: stateless (stateless) and stateful (stateful). For the same trigger, a stateful job cannot be executed in parallel, and the next execution can be triggered only after the last triggered task has been executed. There are two main properties of the job: volatility and durability, where volatility indicates whether the task is persisted to the database store, and durability indicates whether the task is persisted without a trigger association. Both are persisted or persisted when the value is true. A job can be associated with multiple trigger, but a trigger can only associate one job.

In Quartz, Scheduler is created by the Scheduler Factory: Directschedulerfactory or Stdschedulerfactory. The second factory stdschedulerfactory used more, because the directschedulerfactory is not easy to use, need to make a lot of detailed manual coding settings. There are three main types of Scheduler: Remotembeanscheduler, Remotescheduler and Stdscheduler. This article takes the most commonly used stdscheduler as an example to explain. This is also the scheduler class used by the author in the project.

170412. Spring Boot Quartz Introduction

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.