Add ability to stop a running Spring Batch Job from a running application
See original GitHub issueThe current recommended way to run a Spring Batch job is via a Spring Boot uber jar via java -jar myJobApp.jar jobParameter1=foo jobParameter2=bar ...
. This works well and is well adopted by the community. However, the mechanism Spring Boot uses for launching Spring Batch jobs does not include a feature the CommandLineJobRunner
from Spring Batch does (the “legacy” way of running a batch job via a jar file), that’s the ability to stop a running job. With that main class (https://github.com/spring-projects/spring-batch/blob/master/spring-batch-core/src/main/java/org/springframework/batch/core/launch/support/CommandLineJobRunner.java), you can specify from the command line to stop a running job. This will change the status of the job’s JobExecution within the JobRepository to be STOPPING. Spring Batch regularly checks this status and will react accordingly if it’s found. It would be nice to either have a new CommandLineRunner
or new feature added to the JobLauncherCommandLineRunner
to be able to stop a running job in this mechanism.
Issue Analytics
- State:
- Created 6 years ago
- Comments:11 (11 by maintainers)
This feels a bit like another variant of #6035.
We’ve closed #6035 because we don’t want to add additional complexity to the code-base. I’m going to close this one as well and suggest that we create documentation issue to show how to do this programmatically.