Reputation: 290
I have tried to stop my job when it is running. But the job do not stop immediately. It is still running and then throws the log:
2019-12-03 13:23:48 [main] INFO o.s.b.c.r.s.SimpleJobRepository - Parent JobExecution is stopped, so passing message on to StepExecution
2019-12-03 13:23:48 [main] INFO o.s.b.c.s.ThreadStepInterruptionPolicy - Step interrupted through StepExecution
2019-12-03 13:23:48 [main] INFO o.s.batch.core.step.AbstractStep - Encountered interruption executing step remindStep in job remindEntrustPayment : Job interrupted status detected.
How could I terminate Job immediately?
Upvotes: 0
Views: 2664
Reputation: 31710
There is no way to force immediate shutdown, especially when the control is in user's code. The StepInterruptionPolicy
(which defaults to ThreadStepInterruptionPolicy
that you see in your logs) is checked at chunk boundaries, this is when the control goes back to the framework and stops the job (which is explained in the Stopping a job section).
You can ask to stop a job using JobOperator#stop
or by setting StepExecution#setTerminateOnly
in your code when appropriate (using a listener for example).
Upvotes: 1