重试使用ftp:outbound channel通过spring集成发送文件

时间:2013-04-09 15:06:52

标签: spring-batch spring-integration spring-retry

我有一个工作弹簧批处理作业,有两个步骤,我想在ftp发送步骤中添加一个重试逻辑。

  • 第一步从数据库读取并输出xml文件
  • 第二步使用spring integration
  • 将此文件发送到ftp主机

第二步配置如下

<step id="sendFileByFtp" next="moveResource">
     <tasklet ref="ftpJobTasklet" />
</step>
<bean id="ftpJobTasklet" class="com...FtpOutboundTasklet" scope="step">
    <property name="resource" ref="ypportal-siparis-outputFile"></property>
    <property name="ftpChannel" ref="ftpOutputChannel"></property>      
</bean>

ftpOutputChannel配置了一个使用DefaultFtpSessionFactory的ftpClientFactory

<int:channel id="ftpOutputChannel"></int:channel>

<int-ftp:outbound-channel-adapter session-factory="ftpClientFactory" id="ftpOutbound" channel="ftpOutputChannel" remote-directory="inbox" auto-create-directory="true" temporary-remote-directory="tmp" >
</int-ftp:outbound-channel-adapter>

我想在第二步添加重试逻辑,它将在远程ftp主机的连接失败时重试/恢复。

使用spring integration 2.2.2和spring batch 2.1.19

1 个答案:

答案 0 :(得分:1)

您可以使用RequestHandlerRetryAdvice,如此处所述...... http://static.springsource.org/spring-integration/reference/html/messaging-endpoints-chapter.html#message-handler-advice-chain

这里有一个样本...... https://github.com/SpringSource/spring-integration-samples/tree/master/intermediate/retry-and-more

它显示了重试的各种配置(指数退避等)。