JobId in itemwriter in multithreaded app
I need to get JobId in the itemwriter, it is multithreaded web app
Quote:
public void beforeStep(StepExecution stepExecution) {
this.stepExecution = stepExecution;
}
public void write(List<? extends T> items) throws Exception {
ExecutionContext stepContext = stepExecution.getExecutionContext();
long jobId = stepExecution.getJobExecution().getJobId();
}
Using this code returns wrong job id, since beforestep method is called for each job run and so it only returns the latest run jobID.
Is there a any other way to get jobId in item writer.