2013-07-30 42 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

相关问题