I'm using a JobListener
to write a batch execution log file. In my first attempt, my code relied on afterJob()
being called in every case, but I discovered, that it is not called when the execution is stopped via JobOperator.stop(jobExecutionId)
. I also understood that a stopped job can be resumed.
Does the batch API provide a hook for a job to be notified about the stop event?
javax.batch.api.listener.JobListener.afterJob()
:
The afterJob method receives control after the job execution ends.
javax.batch.operations.JobOperator.stop(jobExecutionId)
:
This method notifies the job execution to stop and then returns.
No, batch API currently does not have such hook for job stop event. You'll need to implement this logic in your application. If you find compelling reasons for it, please raise an issue in batch spec and api project.