318.6.4. CamelJobExecutionListener

CamelJobExecutionListener 는 작업 실행 이벤트를 Camel 엔드포인트에 전송하는 org.springframework.batch.core.JobExecutionListener 인터페이스를 구현한 것입니다.

Spring Batch에서 생성한 org.springframework.batch.core.JobExecution 인스턴스는 메시지의 본문으로 전송됩니다. 이전과 후의 호출 후 SPRING_BATCH_JOB_EVENT_TYPE 헤더를 구분하기 위해 BEFORE 또는 AFTER 값으로 설정됩니다.

아래 예제 스니펫에서는 Spring Batch 작업 실행 이벤트를 JMS 큐에 보냅니다.

<bean id="camelJobExecutionListener" class="org.apache.camel.component.spring.batch.support.CamelJobExecutionListener">
  <constructor-arg ref="producerTemplate"/>
  <constructor-arg value="jms:batchEventsBus"/>
</bean>

<batch:job id="myJob">
  <batch:step id="step">
    <batch:tasklet>
      <batch:chunk reader="someReader" writer="someWriter" commit-interval="100"/>
    </batch:tasklet>
  </batch:step>
  <batch:listeners>
    <batch:listener ref="camelJobExecutionListener"/>
  </batch:listeners>
</batch:job>