I am using the @Scheduled annotation in Spring Boot to trigger multiple jobs.
Following is the code snippet:
@EnableBatchProcessing
@EnableScheduling
public class Config extends DefaultBatchConfigurer{
@Autowired
JobLauncher launcher;
@Scheduled
public void run(){
String[] argList = {"A", "B"};
for(String char : argList){
launcher.run(job(),
new JobParametersBuilder().
addString("char", char).
toJobParameters());
}
}
public Job job(){
//Job definition is here.
}
}
However, this triggers the 2 jobs in succession and not in parallel, i.e. the application waits for job with parameter "A" to complete before starting job with paramater "B".
Is there a way I can run these jobs in parallel?
Thanks!
JobLauncher? If so, it's synchronous by default. - Michael Minella