Stopping Spring batch jobs gracefully
Hi,
What is the best way to stop jobs gracefully ?
JobOperator provides stop(executionId) method but it only sends signal, there is no guarantee that post this statement execution the job has stopped.
To handle this, I am running an infinite loop that will getSummary for the execution-id and in the summary I check for the presence of substring status=BatchStatus.COMPLETED. The loop breaks when status is BatchStatus.COMPLETED
Is it the right approach or there is any better way of managing graceful shutdown of Spring batch jobs ?
Please suggest,
Thanks,
Ranbir