简体   繁体   English

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

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

I am using int-file:inbound-channel-adapter to process the file. 我正在使用int-file:inbound-channel-adapter处理文件。

I got 2 int-file:inbound-channel-adapter in 2 difference server but polling same folder. 我在2个差异服务器中获得了2个int-file:inbound-channel-adapter ,但轮询了同一文件夹。

2 listener will listen to 1 same server folder. 2个侦听器将侦听1个相同的服务器文件夹。 Listener 1 not able to process the message because it had been processed by listener 2. Errors shown as below. 侦听器1无法处理该消息,因为它已由侦听器2处理。错误如下所示。

Listener 1 :- 听众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.

Listener 2 :- 听众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}]

So what i suspect is the initiate both of the listener's payload message got the file. 因此,我怀疑是发起方的两个侦听器的有效负载消息都获得了文件。 But after 1 of the listener processed the file already, second listener unable will hit error. 但是在侦听器中的1个已经处理完文件之后,第二个侦听器将无法命中错误。

Part of the code like below:- 部分代码如下:

<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"/>

Appreciate someone can help. 感谢有人可以提供帮助。 Thanks. 谢谢。

Let me guess: you don't want to process the same file on the second server to avoid that error. 让我猜测:您不想在第二台服务器上处理同一文件来避免该错误。 For this purpose you should use FileSystemPersistentAcceptOnceFileListFilter as a reference to the filter of the <int-file:inbound-channel-adapter> . 为此,您应该使用FileSystemPersistentAcceptOnceFileListFilter作为对<int-file:inbound-channel-adapter>filter的引用。 Consider to use some out-of-the-box MetadataStore or implement your own one. 考虑使用一些现成的MetadataStore或实现自己的。

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

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