Skip to content

Commit 1a99961

Browse files
committed
#BAEL-8695: add another way of restart job
1 parent 3f63d98 commit 1a99961

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

spring-batch-2/src/main/java/com/baeldung/restartjob/RestartJobBatchApp.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,10 @@ CommandLineRunner run(JobLauncher jobLauncher, Job job, JobExplorer jobExplorer,
4141
if (lastExecution.getStatus() == BatchStatus.FAILED) {
4242
System.out.println("Restarting failed job execution with ID: " + lastExecution.getId());
4343

44-
final Long restartId = jobOperator.restart(lastExecution.getId());
45-
final JobExecution restartedExecution = jobExplorer.getJobExecution(restartId);
44+
JobExecution restartedExecution = jobLauncher.run(job, jobParameters);
45+
46+
// final Long restartId = jobOperator.restart(lastExecution.getId());
47+
// final JobExecution restartedExecution = jobExplorer.getJobExecution(restartedExecution);
4648

4749
System.out.println("Restarted job status: " + restartedExecution.getStatus());
4850
return;

0 commit comments

Comments
 (0)