Nov 25th, 2010, 06:51 AM
Batch stopped abruptly
I have a batch running on a server. For some reasons, the server is stopped while the batch is running.
The status of the batch job execution is STARTED.
I start the server again and stop that execution (SimpleJobOperator.stop(long)). The status is STOPPING, and it stays so infinitely.
Is there a way to force the job to stop? (timeout, other method to call, ...)
Nov 29th, 2010, 03:11 AM
If the process died (CTRL-9 or server shutdown) the job is, of course, not running. But the JobRepository has no way of knowing because no-one told it before the process died. You have to tell it manually that you know that the execution either failed or should be considered aborted (change its status to FAILED or ABORTED) - it's a business decision and there is no way to automate it. Only change the status to FAILED if it is not restartable, or if you know the restart data is valid. There is a utility in Spring Batch Admin JobService to abort a job execution.
Nov 29th, 2010, 09:15 AM
Thanks for your answer.
Then, we will need to implement something that validates that the stop command has been successfully processed, and if not, change the status to FAILED.