I am using Spring Batch Admin to run batch jobs for our system. We have to run these jobs many times. I am using the rest interface of spring batch admin. I start a new job using Spring RestTemplate.
RestTemplate tpl = new RestTemplate();
tpl.postForLocation(Constants.SPRING_BATCH_ADMIN_URL + "/jobs/myBatchJob;
This works to start the first job but on subsequent jobs the request does not start a new instance of the job. In the job configuration file I have an jobParmatersIncrementer defined
<job id="myBatchJob" xmlns="http://www.springframework.org/schema/batch"
restartable="true" incrementer="jobParametersIncrementer">
<bean id="jobParametersIncrementer"
class="org.springframework.batch.core.launch.support.RunIdIncrementer" />
I have tried changing my postForLocation to
List<JobInstance> jobInstances = jobExplorer.getJobInstances("myBatchJob", 0, 30);
JobParameters jobParameters = jobInstances.get(0).getJobParameters();
RunIdIncrementer runIdIncrementer = new RunIdIncrementer();
JobParameters jobParameters = runIdIncrementer.getNext(jobParameters);
RestTemplate tpl = new RestTemplate();
tpl.postForLocation(Constants.SPRING_BATCH_ADMIN_URL +
"/jobs/myBatchJob?launch=Launch&{parameters}",
"runid",
jobParameters.toString());
It works from the spring batch admin page by clicking the launch button. This is in the parameter edit box
run.id(long)=1
How do you run a job in Spring Batch Admin from another web application more than once?