I wrote a Job of two Steps, with one of two steps being a partitioning step. The partition step uses TaskExecutorPartitionHandler and runs 5 slave steps in threads. The job
There are 2 solutions to your problem, although I don't know the cause.
First, you can use a CommandLineJobRunner
to launch the Job
. See documentation here. This class automatically exits the program at the end of the job and converts the ExitStatus to a return code (COMPLETED
= 0, FAILED
= 1...). The default return code are provided by a SimpleJvmExitCodeMapper
.
The second solution would be to manually call a System.exit()
instruction after your JobLauncher.run()
. You can also convert the ExitStatus
of the Job
manually and use it in your manual exit :
// Create Job
JobLauncher jobLauncher = (JobLauncher) context.getBean("jobLauncher");
Job job = (Job) context.getBean(jobName);
// Create return codes mapper
SimpleJvmExitCodeMapper mapper = new SimpleJvmExitCodeMapper();
// Start Job
JobExecution execution = jobLauncher.run(job, new JobParameters());
// Close context
context.close();
// Map codes and exit
String status = execution.getExitStatus().getExitCode();
Integer returnCode = mapper.intValue(status);
System.exit(returnCode);