I am trying to implement parallel processing using spring boot and spring batch. This batch will be triggered from UI with some required parameters
I need to create steps based on the request parameters, I tried as below,
The rest controller looks,
JobParameters jobParameters = new JobParametersBuilder().addLong("JobID",System.currentTimeMillis())
.addString("fileName", filename)
.addString("buisinessDate", model.getGeneralServiceModel().getBusinessDate())
.addString("source", model.getGeneralServiceModel().getSource())
.toJobParameters();
jobLauncher.run(job, jobParameters);
And the batch config:
Flow masterFlow = (Flow)new FlowBuilder("masterFlow").start(stepOne()).build();
List<Step> steps = new ArrayList<Step>();
for (ConcurrentLinkedQueue date : taskOne.readFile()) {
steps.add(createStep(date));
}
return jobs.get("myJob")
.start(masterFlow)
.next(createParallelFlow(steps))
.end()
.build();
The masterFlow reads the job parameters into its variables, and the readFile() gives the list (based on this the steps has to be created), for this the jobParameters are required.
The problem is:
While starting my application itself the readFile() is getting executed. but I need to get it executed when job triggers through RestController since it has the required parameters.
How can I stop this execution while starting the application?