Spring integration 在事务中创建重试延迟以清除sftp入站通道文件
我有一个Spring integration 在事务中创建重试延迟以清除sftp入站通道文件,spring-integration,spring-transactions,spring-messaging,Spring Integration,Spring Transactions,Spring Messaging,我有一个sftp:inbound channel adapter,它将文件从远程文件夹同步到本地文件夹。当它发现一个扩展名为.xml的文件时,它会创建一条消息和一个新事务,并将其发送到routerChannel通道 approverRouter查看xml内部并确定流程是否可以继续。如果一切正常,则消息将被发送到“okChannel”并向下发送到数据库进行保存。但是,如果情况不正常,则会将消息发送到int:delayer10秒钟,然后重新提交到approverRouter 如果事务成功或失败,则s
sftp:inbound channel adapter
,它将文件从远程文件夹同步到本地文件夹。当它发现一个扩展名为.xml的文件时,它会创建一条消息和一个新事务,并将其发送到routerChannel
通道
approverRouter
查看xml内部并确定流程是否可以继续。如果一切正常,则消息将被发送到“okChannel”并向下发送到数据库进行保存。但是,如果情况不正常,则会将消息发送到int:delayer
10秒钟,然后重新提交到approverRouter
如果事务成功或失败,则sftpCommittedChannel
和sftpledledbackchannel
仅将下载的文件移动到已完成/失败的文件夹中
下面是一些xml来描述这一点:
<int-sftp:inbound-channel-adapter id="..." channel="routerChannel" local-filter="localOnlyXmlFilter" ... >
<int:poller fixed-rate="10000" max-messages-per-poll="-1">
<int:transactional transaction-manager="transactionManager" synchronization-factory="syncFactory" />
</int:poller>
</int-sftp:inbound-channel-adapter>
<!-- Takes Message<Map> makes sure all files exist and are valid MD5 checked -->
<int:router input-channel="routerChannel" ref="approverRouter" method="resolveRoute"/>
<bean id="approverRouter" class="com.example.app.readers.ApproverRouter">
<property name="errorChannel" value="errorChannel"/>
<property name="retryChannel" value="myRetry"/>
<property name="okChannel" value="transformHashesToList"/>
<property name="timeout" value="${timout}"/>
</bean>
<int:delayer id="delayer" input-channel="myRetry" output-channel="routerChannel" default-delay="10000"/>
<int:transaction-synchronization-factory id="syncFactory">
<int:after-commit channel="sftpCommittedChannel"/>
<int:after-rollback channel="sftpRolledBackChannel"/>
</int:transaction-synchronization-factory>
我的问题是,当消息被发送到延迟器时,轮询器中创建的事务成功完成。我认为这是因为当消息到达int:delayer
(通过retryChannel)时,它不再位于同一原始线程中
我想我需要的是一个同步的延迟器,它会增加延迟,但会将消息保持在原始事务中。感觉我的设计不对
正常人会做什么来创建重试延迟,并在成功或失败时仍然整理sftp文件夹。您可以添加无状态请求处理程序重试建议;可以根据退避设置挂起线程
见和