question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add ability to stop a running Spring Batch Job from a running application

See original GitHub issue

The 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:closed
  • Created 6 years ago
  • Comments:11 (11 by maintainers)

github_iconTop GitHub Comments

2reactions
wilkinsonacommented, Mar 4, 2018

This feels a bit like another variant of #6035.

0reactions
philwebbcommented, Mar 19, 2018

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Trigger and Stop a Scheduled Spring Batch Job
Firstly, we have a class SpringBatchScheduler to configure scheduling and batch job. A method launchJob() will be registered as a scheduled task ...
Read more >
Configuring and Running a Job - Spring
In this scenario, it is entirely up to the developer to ensure that a new JobInstance is created. However, Spring Batch does provide...
Read more >
How can I prevent my Spring Boot Batch application from ...
Try to create application.properties file in test resources (e.g. src/main/resources) with this content: spring.batch.job.enabled=false.
Read more >
Guide to Spring Batch Processing | Toptal
This Spring Batch tutorial will walk you through the process step-by-step. ... non-interactive, and frequently long running, background execution—is widely ...
Read more >
Spring Batch Job Configuration - Java Development Journal
In this article, we will take a deep dive into Spring Batch Job Configuring and Running the Job and its various flavors.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found