0
votes

I am executing the batch job programatically using org.springframework.batch.core.launch.JobLauncher

In my code, I have statement like

JobExecution result = jobLauncher.run(job, parameters);

Most of the batch jobs I have run with parameters, but one of my batch job does not take any parameters. So, I have set up that job with org.springframework.batch.core.launch.support.RunIdIncrementer

In order to user incrementer, I have to provide -next option to JobLauncher. How do I pass my jobLauncher this -next parameter?

2

2 Answers

0
votes

I have same problem and I dont found any solution how to add "next" param in code. Instead of this you can put current time as param:

Map<String, JobParameter> jobParameterMap = new HashMap<String, JobParameter>();
jobParameterMap.put("date", new JobParameter(new Date()));
JobExecution exec = jobLauncher.run(job, new JobParameters(jobParameterMap));
0
votes

There isn't an equivalent on the JobLauncher to increment the JobParameters. The way to launch a job this way is using the JobOperator#startNextInstance(String jobName).