Spring batch 不能';t使用ExecutionContextPromotionListener在目标步骤中接收值
我想在批处理作业中将一些信息从一个步骤传递到另一个步骤。创建了BStepListener,其中存储了上下文中的值,但在另一个步骤中创建的tasklet[SendMailTasklet]不会使用相同的值。我在哪里失踪 作业配置Spring batch 不能';t使用ExecutionContextPromotionListener在目标步骤中接收值,spring-batch,Spring Batch,我想在批处理作业中将一些信息从一个步骤传递到另一个步骤。创建了BStepListener,其中存储了上下文中的值,但在另一个步骤中创建的tasklet[SendMailTasklet]不会使用相同的值。我在哪里失踪 作业配置 <job id="bJob" xmlns="http://www.springframework.org/schema/batch"> <step id="step1"> <tasklet> <
<job id="bJob" xmlns="http://www.springframework.org/schema/batch">
<step id="step1">
<tasklet>
<chunk reader="bReader" writer="bWriter" processor="bProcessor"
commit-interval="10" />
</tasklet>
<batch:next on="COMPLETED" to="sendEmail"/>
<listeners>
<listener ref="bStepListner"/>
<listener ref="bPromotionListener"/>
</listeners>
</step>
<step id="sendEmail">
<tasklet ref="sendMailManager"/>
</step>
</job>
<bean id="bStepListner" class="com.listener.BStepListener" scope="step"/>
<bean id="bPromotionListener" class="org...ExecutionContextPromotionListener">
<property name="keys" value="msg"/>
</bean>
<bean id="sendMailManager" class="com.mail.SendMailTasklet" scope="step">
SendMailTasklet.java
public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext)
throws Exception {
logger.info("Sending Email service....");
String message = (String)chunkContext.getStepContext().getJobExecutionContext().get("msg");
this.sendMail();
return RepeatStatus.FINISHED;
}
我认为(我必须仔细检查代码)我们不能保证调用顺序侦听器。因此,提升侦听器可能会在您的被调用之前被调用。尝试使用compositespexecutionlistener
包装侦听器列表,以便保留顺序
您可以在此处阅读更多有关复合执行侦听器的信息:我认为(我必须仔细检查代码),我们不能保证调用顺序侦听器。因此,提升侦听器可能会在您的被调用之前被调用。尝试使用compositespexecutionlistener
包装侦听器列表,以便保留顺序
您可以在此处阅读更多有关复合执行侦听器的信息:我认为(我必须仔细检查代码),我们不能保证调用顺序侦听器。因此,提升侦听器可能会在您的被调用之前被调用。尝试使用compositespexecutionlistener
包装侦听器列表,以便保留顺序
您可以在此处阅读更多有关复合执行侦听器的信息:我认为(我必须仔细检查代码),我们不能保证调用顺序侦听器。因此,提升侦听器可能会在您的被调用之前被调用。尝试使用compositespexecutionlistener
包装侦听器列表,以便保留顺序
您可以在此处阅读有关CompositeSpexecutionListener
的更多信息:
public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext)
throws Exception {
logger.info("Sending Email service....");
String message = (String)chunkContext.getStepContext().getJobExecutionContext().get("msg");
this.sendMail();
return RepeatStatus.FINISHED;
}