Monday, August 3, 2020

Introduction to Quartz Scheduler

Quartz is a job scheduling library that can be integrated into a wide variety of Java applications.
Quartz is generally used for enterprise class applications to support process workflow, system management actions and to provide timely services within the applications.
You can create complex schedules for executing any job. Examples are e.g. tasks that run daily, every other Monday 8:30 p.m. or only on the last day of every month. 

You can download Quartz from http://quartz-scheduler.org/downloads

Components:
============
Quartz job:
Quartz job is used for the logic or code which you want to execute. It implements org.quartz.Job interface.

Quartz trigger:
Quartz trigger is used to define the moment when the quartz scheduler will execute quartz’s job.

Types of quartz trigger:
1. SimpleTrigger – SimpleTrigger setting start time, end time, repeat count and repeat interval for quartz’s job.
2.CronTrigger – CronTrigger uses cron expressions to specify the moment when to execute quartz’s job.
 A cron expression is made up of seven sub expressions:
Seconds
Minutes
Hours
Day-of-Month
Month
Day-of-Week
Year (optional field)
3. Scheduler class – Scheduler class is used to connect the quartz job and quartz trigger together and execute the job.
4.JobListener:
JobListener provides the facility to track the status of running jobs. To write a JobListener we have to implements the JobListener interface.

Quartz API:
===========
The key interfaces of the API are:
Scheduler – the primary API for interacting with the scheduler of the framework
Job – an interface to be implemented by components that we wish to have executed
JobDetail – used to define instances of Jobs
Trigger – a component that determines the schedule upon which a given Job will be performed
JobBuilder – used to build JobDetail instances, which define instances of Jobs
TriggerBuilder – used to build Trigger instances




No comments:

Post a Comment

ES12 new Features