【发布时间】:2017-08-11 13:09:53
【问题描述】:
我有以下 Spring Integration 配置:
<int-file:inbound-channel-adapter
auto-startup="true"
channel="localInboundFilesChannel"
directory="${in.received}"
auto-create-directory="true">
<int:poller fixed-rate="60" time-unit="SECONDS"/>
</int-file:inbound-channel-adapter>
<int-file:outbound-gateway
auto-startup="true"
request-channel="localInboundFilesChannel"
reply-channel="localProcessingFilesChannel"
directory="${in.processed}"
auto-create-directory="true"
delete-source-files="true"
requires-reply="false"
/>
轮询器每 1 分钟运行一次,将文件从一个文件夹复制到另一个文件夹并执行其他操作(我不提供后续步骤的代码)。
但是当我将一些文件放入目录时,我看到它被读取了两次,所以在日志中看到:
2017-08-11 14:06:31,250 INFO org.springframework.integration.file.FileReadingMessageSource - Created message: [GenericMessage [payload=target\received\request.csv, headers={id=1f4d1ac0-823e-f3b0-2554-caae8e330682, timestamp=1502453191250}]]
2017-08-11 14:06:31,250 INFO org.springframework.integration.file.FileReadingMessageSource - Created message: [GenericMessage [payload=target\received\request.csv, headers={id=73076423-f1ba-7cbe-a4c2-c5f02220e3f5, timestamp=1502453191250}]]
我应该如何解决它? Spring Integrations bean 配置有什么问题吗?
【问题讨论】:
-
是每分钟发生一次还是每分钟发生一次?
-
也许您以某种方式加载了应用程序上下文的 2 个副本?
-
我们有没有机会在我们身边玩一个简单的应用程序?您现在显示的是该组件的标准行为。开箱即用地有这样一个意想不到的状态真的很糟糕......
-
是的,应用程序上下文的 2 个副本已加载,这是问题的原因。谢谢