I have a Job for monthly invoicing. Current job consist from few Steps. I am passing data between Steps using StepExecution and ExecutionContextPromotionListener. We are going to run Job for each invoice. So we will have multiple instances of a job in parallel which pass data between Steps .
implements ItemWriter<Invoice> {
@BeforeStep
public void saveStepExecution(StepExecution stepExecution) {
this.stepExecution = stepExecution;
}
}
@Bean
public ExecutionContextPromotionListener promotionListener() {
ExecutionContextPromotionListener listener = new ExecutionContextPromotionListener();
listener.setKeys(new String[] {"invoice"});
return listener;
}
I am pretty sure it`s not thread safe. Could somebody advise any solution for Spring Batch?
Any advice or explanation if I am wrong