【问题标题】:file inbound-channel-adapter not creating messages文件入站通道适配器不创建消息
【发布时间】:2013-07-30 15:55:02
【问题描述】:

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

在生产者模块中,我们有以下代码。当我在传入文件夹中删除大约 100 个文件时,大约 90 个文件已处理并移至进程文件夹,但 10 个文件没有移至进程文件夹。

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

     ....

[07/30/13 07:34:23:023 EDT] [taskExecutor-3] 调试 org.springframework.integration.file.FileReadingMessageSource 添加到队列:[test.xml] [07/30/13 07:34:23:023 EDT] [taskExecutor-3] 调试 org.springframework.integration.endpoint.SourcePollingChannelAdapter 在轮询期间未收到任何消息,返回“false”

       .... 

成功案例

       ....

[07/30/13 07:34:32:032 EDT] [taskExecutor-1] 调试 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={时间戳=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>

【问题讨论】:

    标签: file adapter spring-integration


    【解决方案1】:

    这一般意味着locker无法锁定文件(可能是因为文件正在其他地方使用)。

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

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

    【讨论】:

    • 谢谢加里。这些文件是由不同的系统生成的。我们将尝试使用临时文件名的方法并让您知道结果。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多