I have a spring batch job Ex: Job2 which runs in partitions. The primary job takes about 1-2 hours to complete.
I am trying to introduce a precondition which is a new Job Job1 (And it has to be a Job, can not be a step) and it should execute before the Job Job2. This also takes 20-30 mins to execute, basically it refines the data which was being processed as raw from long time.
@Bean
public Job job1() {
return this.jobBuilderFactory.get("Job1").listener(jobListener()).incrementer(new RunIdIncrementer())
.start(anotherStep()).build();
}
@Bean
public Job job2() {
Step step = stepBuilderFactory.get("Job2Step").listener(readListener()).listener(stepListener())
.listener(writeListener()).<Item, Item>chunk(1).reader(jobReader()).processor(jobProcessor())
.writer(jobWriter()).build();
return jobBuilderFactory.get("Job2").listener(jobListener()).start(step).build();
}
if (Job1 is running) {
//Pause Job2 }
As I don't want to change existing functionality in the primary job, Can we pause the primary job Job2 until the main Job1 is not completed. Note: These jobs get triggered every 3-4 hours