The first thing you should know is Joblauncher, which cannot be used to restart an already running job. The reason you get a "JobExecutionAlreadyRunningException" is because the parameter that you are passing is already in the database and therefore you are getting this exception.
In the spring package, the task can be restarted if it is completed with the status "FAILED" or "STOPPED".
JobOperator has a reload method that you can use to restart a failed job by passing a run identifier that has been filled with the status "FAILED" or "STOPPED".
Please note that the task cannot be restarted if it is completed with the status "FINISHED". In this case, you will need to send a new task with new task parameters
If you want to manually set the status of the job as a failure, run the query below and restart the job using the JobOperator.restart () method.
update batch_job_execution set status="FAILED", version=version+1 where job_instance_id=jobId;
Incorrect transaction management processing may be one of the possible reasons why the status of your work is not updated with the status βFAILEDβ. Verify that the transaction has completed even if the job encountered a run-time exception.
source share