318.6.4. CamelJobExecutionListener
CamelJobExecutionListener 是 org.springframework.batch.core.JobExecutionListener 接口实施,将作业执行事件发送到 Camel 端点。
Spring Batch 生成的 org.springframework.batch.core.JobExecution 实例作为消息正文发送。要区分 before- 和 after-callbacks 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>