These days almost each and every type of applications from standalone to enterprise level have jobs, that it has to execute at a particular time or want to repeat the same job at a particular interval. So, if your application is running on Java Stack then we have a very good robust and open source framework to meet our scheduling needs.
Here I am talking about the Quartz scheduler framework which has been completely written in java , fault tolerant and can integrate very easily with any framework. Before we start looking into the Quartz integration with Spring , first try to look at what are important components in Quartz Scheduler Framework.
Quartz Scheduler Framework is basically consist of 3 important components that are also the backbone of framework.
1. Quartz Job: Quartz job represents part of your application that you want to execute at an interval. So, basically it is going to contain some logic (written in java) that is going to repeat itself at a particular interval.
e.g : Logic of moving the contents of your database to some backup repository that you want to execute every weekend. So, here code that is responsible for moving your data will be the job.
2. Quartz Trigger : Now once your job is ready , you need someone who can take care of it , that means someone who will make this job executed. For this Quartz Scheduler Framework provide us two types of trigger .
• Simple Trigger – It will allow you to set start time , end time and repeat interval.
• Cron Trigger – Here , instead of defining all those params start time ,end time and repeat interval with a value , you can define those with the help of a unix cron expression.
3. Quartz Scheduler : Now we need a component which can bind both the above components together and can order trigger to execute the on basis of params defined above.
I know it will be much more clear if we have an example for each of the components but don’t worry in my next post where we will integrate Quartz with Spring we will see a full fledge running application using Quartz Scheduler Framework.
Before finishing this post I want to make some points that will focus on why to use Quartz , if your application required job scheduling.
Benefits of Quartz Scheduler Framework :
• Complete Opensource.
• Already accepted across the industry.
• Hassle free integration with other frameworks.
• Can executes any number of jobs.
• Can participate in JTA transactions.
• Load Balancing.
• Lot of inbuilt plugins are available to meet different needs.
Happy Quartz Scheduling
Latest posts by Saurabh Jain (see all)
- java.lang.IncompatibleClassChangeError: Found interface org.apache.hadoop.mapreduce.TaskInputOutputContext, but class was expected - August 8, 2014
- org.datanucleus.store.rdbms.exceptions.MappedDatastoreException: INSERT INTO “TABLE_PARAMS” – Hive with Kite Morphlines - July 17, 2014
- java.io.IOException: can not read class parquet.format.PageHeader: null – Hive - July 12, 2014