I need a spring batch program which should do the following task. Batch program will be scheduled to run every 5 seconds. I will take care of the scheduling. All I need is a batch program and table DDL script.
Technologies, Spring batch, Jdk1.6 and Quartz API, postgresql 9.2.
Table name, JOBDETAILS
Columns are, Jobid, jobname, rest_web_service_url, crontab_trigger_expression
jobid is primary key and sequence. Add more columns if it requires for this logic.
- Batch program should read the jobname,business_description,rest_web_service_url and crontab trigger expression from the table. Each job in the table will have different cron trigger, different rest webservice url.
- Based on crontab expression,it should call the rest_webservice.
Let's say...I have the following data in the jobdetails table.
jobid = 1
jobname=JobA
rest_web_service_url = [login to view URL]
crontab_trigger_expression = 0/30 * * * * ?
As per cron trigger for JobA, the rest_web_service_url should be called every 30 seconds. Remember, Batch program will be scheduled to run every 5 seconds, so batch will check and call the service on every 30 seconds. Once job has been fired, you can update job_fired_time and next_job_fire_time in the tables. ( you can create more tables/column if you want to!). FYI, You can get all these details if you use CronTrigger object.
The above example data is for every 30 seconds, but there will be a many jobs with different crontriggers/expression. Example, JobB - Every friday at 10 PM. JoBC - Every day at 11 PM, JobD - 1st day of every month at night 11 PM etc.
Make sure that job will be fired exactly once based on crontrigger for each job.
I need only a batch program and postgres tables ddl script.