자기개발/검색한 자료 정리

spring batch tasklet getJobExecution(spring 배치 tasklet에서 jobId 얻기 위해 JobExecution 조회)

실버블렛 2022. 7. 3. 12:22
반응형

# spring batch tasklet getJobExecution(spring 배치 tasklet에서 jobId 얻기 위해 JobExecution 조회)

 

## tasklet 에서 jobId 가지고 오기 위해 getJobExecution 사용법

 

```

public class ChangingJobExecutionContextTasklet implements Tasklet {

    /** {@inheritDoc} */
    @Override
    public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception {
        // set variable in JobExecutionContext
        chunkContext
                .getStepContext()
                .getStepExecution()
                .getJobExecution();
            

        // exit the step
        return RepeatStatus.FINISHED;
    }

}

```

 

참고사이트: https://stackoverflow.com/questions/8117060/storing-in-jobexecutioncontext-from-tasklet-and-accessing-in-another-tasklet

 

#spring batch #spring batch tasklet #spring batch tasklet getJobExecution jobId

반응형