file inbound-channel-adapter不创建消息

时间:2013-07-30 15:55:02

标签: file adapter spring-integration

我们正在研究POC以使用Spring集成和Rabbit MQ。我们有两个模块生产者模块和消费者模块都在不同的JVM中运行。生成器模块一旦新文件到达就侦听文件夹(输入文件夹),创建消息然后推送到(incoming.q.in)队列并移动到进程文件夹。

在生产者模块中,我们有以下代码。当我在传入文件夹中丢弃大约100个文件时,处理了大约90个文件并移动到进程文件夹,但是10个文件没有移动到进程文件夹。

对于失败的情况,这些是日志文件中的消息

     ....

[07/30/13 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在民意调查期间未收到任何消息,返回'false'

       .... 

成功案例

       ....

[07/30/13 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 :(得分:1)

这通常意味着储物柜无法锁定文件(可能是因为文件在其他地方使用)。

BTW,像这样的应用程序的一个常见错误是“就地”复制文件,这样消费者可能会看到一个不完整的文件。

避免这些问题的常用技巧是使用临时名称复制文件,并仅在完全写入时重命名。