How can I get jobId in ItemWriter in spring package

Is it possible to get jobId or JobName in ItemWriter in spring package.

I read about the end of the binding , but not sure how to use it to get the job name or job id in Item Writer.

I configured my author as

    <bean id="myWriter" ref="com.eg.man.EodWriter" scope="step">
     <property name="jobInstanceId" value="#{stepExecution.jobExecution.jobId}"/>
    </bean>

but I don’t know how to use it in the writer class to get the value.

Edit I also found this link, which says that you can get the identifier in the record, but again, how to use it in the writer class

+3
source share
1 answer

I don't know how your method does this with xml, but here is how I will do it:

( ),

private Long jobId;

@BeforeStep
public void getInterstepData(StepExecution stepExecution) {
    JobExecution jobExecution = stepExecution.getJobExecution();
    this.jobId = jobExecution.getJobId();
}

, .

, .

+4

All Articles