• 카테고리

    질문 & 답변
  • 세부 분야

    백엔드

  • 해결 여부

    미해결

reader, writer, processor에서 적용

23.08.02 11:34 작성 조회수 265

0

tasklet이 아닌 chunk 단위에서 step 간에 데이터 공유를 하고 싶다면 어떤 식으로 코드를 짜야 할까요 ?

찾아보니 방법이 달라서 적용이 힘든데 궁금합니다..

답변 1

답변을 작성해보세요.

0

안녕하세요 :)

아래의 코드[0] 처럼 chunkContext에서 저장하고 꺼내올 수 있습니다.

ExecutionContext executionContext = chunkContext
   .getStepContext()
   .getStepExecution()
   .getJobExecution()
   .getExecutionContext();
executionContext.put("someKey", "hello!!");

혹시 위의 방법으로 해결이 안될까요?

[0] https://github.com/junngo/spring-batch-tutorial/blob/master/src/main/java/com/example/SpringBatchTutorial/job/MultipleStep/MultipleStepJobConfig.java#L57