I am using int-file:inbound-channel-adapter
to process the file.
I got 2 int-file:inbound-channel-adapter
in 2 difference server but polling same folder.
2 listener will listen to 1 same server folder. Listener 1 not able to process the message because it had been processed by listener 2. Errors shown as below.
Listener 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 :-
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.
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>
. Consider to use some out-of-the-box MetadataStore
or implement your own one.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.