Recovering from abnormal shutdown (with a persistent database)
We have a long running spring context that is a part of our batch + integration system, if the container that runs batch features shuts down abnormally while a job is running jobExplorer.findRunningExecutions("jobName") calls for that job result in atleast one result when the container is back up.
We have our own pojo that is timed via cron to call jobOperator.startNextInstance("jobName") to run jobs that aren't already running (no results via .findRunningExecutions(String))
Is there something built in spring batch to avoid this? Like marking all the endtimes and results for "open" jobs when the context is starting up?
Or am I perhaps doing something wrong and this should be done automatically?
Environment is a tomcat7 with a mysql db for batch (and generic storage for the jobs).
edit: to clarify the situation, we have some jobs that run hourly, but can take over an hour, so we don't want to run the job again if the old instance is still running