Job scheduling with Quartz

Source: Internet
Author: User
Tags websphere application server

Introduction: Quartz is an open source project that provides a rich set of job schedules. In this article, the software engineer Michael Lipton and the IT architect Soobaek Jang the Quartz API, starting with a general overview of the framework and ending with a series of code samples showing the quart basic features. After reading this article and looking at the code examples, you should be able to apply the basic features of Quartz to any Java™ application.

Modern WEB application frameworks evolve in scope and complexity, and each underlying component of the application must evolve accordingly. Job scheduling is a general requirement for Java applications in modern systems and is a constant requirement for Java developers. Although the current scheduling technology has developed a lot compared to the original database trigger flags and independent scheduler threads, job scheduling is still not a small problem. The most appropriate solution for this problem is the Quartz API from Opensymphony.

Quartz is an open source job scheduling framework that provides a simple but powerful mechanism for job scheduling in Java applications. Quartz allows developers to schedule jobs based on time intervals (or days). It implements a many-to-many relationship between a job and a trigger, and it can associate multiple jobs with different triggers. An application that consolidates Quartz can reuse jobs from different events, and can combine multiple jobs for one event. Although you can configure Quartz by using the properties file, which can specify the JDBC transaction's data source, global job and/or trigger listeners, plug-ins, thread pools, and more, it is not integrated with the context or reference of the application server at all. The result is that the job does not have access to the internal functions of the WEB server; For example, when using the WebSphere application server, jobs scheduled by Quartz do not affect the dynamic caching and data sources of the server.

This article describes the Quartz API using a series of code examples, demonstrating its mechanisms such as jobs, triggers, job warehouses, and properties.

Entry

To start using Quartz, you need to configure your project with the Quartz API. The steps are as follows:

Download the Quartz API.

Unzip and place the Quartz-x.x.x.jar in the project folder, or place the file in the project's classpath.

Place the jar files in the core and/or optional folders in the project's folder or project's classpath.

If you use Jdbcjobstore, place all the JDBC jar files in the project's folder or project's classpath.

For the convenience of the reader, I have compiled all the necessary files, including the DB2 JDBC file, into a zip file. See download section for download code.

Now take a look at the main components of the Quartz API.

Jobs and triggers

The two basic units of the Quartz dispatch package are jobs and triggers. A job is an executable task that can be scheduled, and a trigger provides a schedule for the job. Although the two entities are easy to fit together, there is a reason for separating them in Quartz, and it is also beneficial.

By separating the work to be performed from its schedule, Quartz allows the scheduling trigger to be modified without losing the job itself or the context of the job. Also, any single job can have multiple triggers associated with it.

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.