繁体   English   中英

在不同的服务器中触发2个spring集成,但具有1个相同的文件轮询文件夹

[英]Trigger 2 spring integration in different server but with 1 same file polling folder

我正在使用int-file:inbound-channel-adapter处理文件。

我在2个差异服务器中获得了2个int-file:inbound-channel-adapter ,但轮询了同一文件夹。

2个侦听器将侦听1个相同的服务器文件夹。 侦听器1无法处理该消息,因为它已由侦听器2处理。错误如下所示。

听众1:-

2014-12-20 22:15:27.608 [task-scheduler-3] DEBUG org.springframework.integration.file.FileReadingMessageSource - Added to queue: [/folder/101.txt]

2014-12-20 22:15:27.715 [task-scheduler-3] DEBUG org.springframework.integration.file.FileWritingMessageHandler - org.springframework.integration.file.FileWritingMessageHandler@502a3135 received message: [Payload=/folder/101.txt][Headers={timestamp=1419084927715, id=f5bb68b3-0eac-40a6-8fcf-8ba54fc295af}]
2014-12-20 22:15:27.724 [task-scheduler-3] INFO  org.springframework.integration.file.FileWritingMessageHandler - Failed to move file '/folder/101.txt'. Using copy and delete fallback.

听众2:-

2014-12-20 22:15:27.585 [task-scheduler-6] DEBUG org.springframework.integration.file.FileReadingMessageSource - Added to queue: [/folder/101.txt]

2014-12-20 22:15:27.711 [task-scheduler-6] DEBUG org.springframework.integration.file.FileWritingMessageHandler - org.springframework.integration.file.FileWritingMessageHandler@1447034b received message: [Payload=/folder/101.txt][Headers={timestamp=1419084927710, id=2177d3cd-fbd9-4412-98d1-48ce84874b53}]

因此,我怀疑是发起方的两个侦听器的有效负载消息都获得了文件。 但是在侦听器中的1个已经处理完文件之后,第二个侦听器将无法命中错误。

部分代码如下:

<int-file:inbound-channel-adapter id="Id1" directory="/folder" prevent-duplicates="false">
    <int:poller id="poller" fixed-rate="10000" max-messages-per-poll="1" />
</int-file:inbound-channel-adapter>

<int-file:outbound-gateway 
    request-channel="Id1" reply-channel="Id1Processing"
    directory="/folder/backup}" delete-source-files="true"/>

感谢有人可以提供帮助。 谢谢。

让我猜测:您不想在第二台服务器上处理同一文件来避免该错误。 为此,您应该使用FileSystemPersistentAcceptOnceFileListFilter作为对<int-file:inbound-channel-adapter>filter的引用。 考虑使用一些现成的MetadataStore或实现自己的。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM