簡體   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