我有以下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"
/>
Poller每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配置中是否存在任何问题?
答案 0 :(得分:0)
在声明bean FileReadingMessageSource
时,添加一个过滤器org.springframework.integration.file.filters.AcceptOnceFileListFilter
。有关更多信息,请参见IntegrationFlows with FileReadingMessageSource triggering job twice for same input file