Currently I have restart spring-batch job in place which is running each hour and checking DB via JobExplorer for job instances which failed, it picks up latest job instance for job which is failed and restarts latest execution. This works fine but we have now new request to restart not only latest instance but all instances which fall in X day window and we should restart one at time from oldest one until it falls out of this window.
Example:
- Job
Ahas instancejobInstance1which fail at 8pm - Job
Ahas instancejobInstance2which fail at 9pm - restart kicks in first time at 10pm and first restarts
jobInstance1 jobInstance1now succeed- restart kicks in second time at 11pm and restarts
jobInstance2
I am thinking about two options:
- Use
JobExplorerand combination ofList<JobInstance> getJobInstances(String jobName, int start, int count);andint getJobInstanceCount(String jobName) throws NoSuchJobException;and to walk through list to find what I am looking for by checking start time - Extend
JdbcJobInstanceDaoand write my own query againstJOB_INSTANCEtable joined withJOB_EXECUTIONand use that
Is there better way to fetch all failed job instances of some job which are at most 3 days old and sort them oldest first?
What do you think about option 1 and 2 if there is no better way?
Aucun commentaire:
Enregistrer un commentaire