2013-07-30 44 views
0

我們正在開發一個使用Spring集成和Rabbit MQ的POC。我們有兩個模塊生產者模塊和消費者模塊都運行在不同的JVM中。只要新文件到達,生產者模塊會在文件夾(輸入文件夾)上偵聽,創建消息,然後推送到(incoming.q.in)隊列並移動到處理文件夾。文件入站通道適配器未創建消息

在生產者模塊中我們有下面的代碼。當我在傳入文件夾中刪除大約100個文件時,大約有90個文件已處理並移動到處理文件夾,但有10個文件未移動到處理文件夾。

對於失敗的情況下,這些是在日誌文件

 .... 

消息[13年7月30日07:34:23:023 EDT] [了taskExecutor-3] DEBUG org.springframework.integration.file。 FileReadingMessageSource添加到隊列中:[test.xml] [07/30/13 07:34:23:023 EDT] [taskExecutor-3] DEBUG org.springframework.integration.endpoint.SourcePollingChannelAdapter在輪詢期間收到否消息,返回'假'

 .... 

成功案例

 .... 

[13年7月30日07:34:32:032 EDT] [了taskExecutor-1] DEBUG org.springframework.integration.file.FileReadingMessageSource添加到隊列:[test_0.xml] [07/30/13 07:34:32:032 EDT] [taskExecutor-1] INFO org.springframework.integration.file.FileReadingMessageSource創建消息:[[Payload =/apps/incoming/test_0.xml] [Headers = {timestamp = 1375184072466 ,ID = d8d4cea4-A25D-4869-b287-e76cfb76f554}]]

 .... 

下面是代碼

<file:inbound-channel-adapter id="inboundAdapter" channel="inboundChannel" directory="file:${incoming_folder}" prevent-duplicates="true" filename-pattern="*.*" auto-startup="true" > 
    <int:poller id="fileInboudPoller" fixed-rate="3" receive-timeout="3" time-unit="SECONDS" max-messages-per-poll="1" task-executor="taskExecutor"/> 
    <file:nio-locker /> 
</file:inbound-channel-adapter> 

回答

1

它通常意味着鎖櫃無法鎖定文件(大概是因爲該文件正在其他地方使用)。

順便說一句,像這樣的應用程序的常見錯誤是「就地」複製文件,使消費者可能會看到一個不完整的文件。

避免這些問題的常用技術是使用臨時名稱複製文件,並僅在完全寫入時重命名該文件。

+0

謝謝加里。這些文件由不同的系統生成。我們將嘗試使用臨時文件名方法並讓您知道結果。 – Mohan

+0

它工作完美。 – Mohan

相關問題