Jan 17th, 2010, 02:37 PM
Async job already running check
We are using job launcher with async. task executor , i.e. jobLauncher.run returns immedatelly.
jobLauncher.run is being called periodically by timer event.
Upon each timer call of jobLauncher.run we want to check whether previous job execution is complete. If not, this timer event should be just ignored.
Initially we launched execution with "new JobParameters()". So we were able to catch JobExecutionAlreadyRunningException and act correctly if previous execution is still in progress. But, if previous execution is complete, we are getting JobInstanceAlreadyCompleteException (because parameters are the same).
On the other hand, if we change parameters upon each event , we get rid of JobInstanceAlreadyCompleteException but also don't get JobExecutionAlreadyRunningException that we need.
Of course we can use some static flag or other tricks. But doesn't Spring Batch provide API to check if ANY execution of particular job is in progress , with no depend on parameters ?
Many thanks in advance.
Jan 17th, 2010, 03:37 PM
why don't you use the JobExplorer to get the JobExecutions of a given job? That way you can figure out if an instance of a particular Job is still running