Quartz Spring Integration Example
Quartz scheduler is popular java open source to schedule jobs. It is best fit for standalone, medium or large applications. Its also very famous and mature open source tools which can be use for any java applications without much worrying. It provide many functionality and here we will integrate with spring and schedule our job using Cron expression.
Note: If you are new to Cron please go through this CronMaker web site where you could build validate your cron expression.
Below are needed:
- Eclipse 4.0 or above
- JDK 1.8
- Quartz version 2.1.7
- Maven 3.2
- Below is final project structure:
- spring-context.xml: This is main configuration where we will create beans and include cron expression to schedule our job:
- Cron-Schedule.properties: I have many exprssion for use but for this tutorial using “cron.schedule.time= 0/10 * * ? * MON-SUN *” which will run our schedule job every 10 seconds.
- SampleJob.java: Java class where method “executeScheduleJob(String value1, String value2)” taking two parameter, both are String.
- SampleJobTestApp: Test class to load Spring context file and run the application:
Download project source code: SpringQuartzIntegration