2015-09-25 122 views
2

弹簧入站通道适配器出现问题。导入新文件的效果非常好。 但是选项prevent-duplicates="false"似乎无法正常工作 - 当具有相同名称的文件保存到指定的目录时,它不会被导入。弹簧入站通道适配器prevent-duplicates = false不起作用

入站通道适配器的定义:

<file:inbound-channel-adapter id="batchFilesDemo" directory="#{baseDirectoryDemo}" prevent-duplicates="false" 
     filename-regex="^(.*)-(\d+)\.csv" comparator="fileOrderComparator"> 
     <int:poller fixed-rate="1000" /> 
    </file:inbound-channel-adapter> 

提前任何建议谢谢!

+0

请与我们分享您使用的Spring集成版本 –

回答

0

刚刚与Spring集成测试4.2是:

<inbound-channel-adapter id="adapterWithRegexPattern" 
     directory="d:\tmp\" 
     prevent-duplicates="false" 
     filename-regex="^.*\.txt"> 
    <integration:poller fixed-rate="1000"/> 
</inbound-channel-adapter> 

<integration:chain input-channel="adapterWithRegexPattern"> 
    <file-to-string-transformer/> 
    <integration:logging-channel-adapter level="FATAL" log-full-message="true"/> 
</integration:chain> 

而且我的日志是这样的:

[task-scheduler-1] ERROR: org.springframework.integration.handler.LoggingHandler - GenericMessage [payload=1, headers={file_originalFile=d:\tmp\1.txt, id=0dc6932a-3007-28bf-41e6-c1d8e3fcc91f, file_name=1.txt, timestamp=1443197583589}] 
[task-scheduler-1] ERROR: org.springframework.integration.handler.LoggingHandler - GenericMessage [payload=2, headers={file_originalFile=d:\tmp\2.txt, id=e0f624eb-33b5-297d-7fb9-89904fc01a7a, file_name=2.txt, timestamp=1443197584560}] 
[task-scheduler-2] ERROR: org.springframework.integration.handler.LoggingHandler - GenericMessage [payload=1, headers={file_originalFile=d:\tmp\1.txt, id=bd680d29-02d9-a5e8-4f8e-c14200315ed0, file_name=1.txt, timestamp=1443197585559}] 
[task-scheduler-1] ERROR: org.springframework.integration.handler.LoggingHandler - GenericMessage [payload=2, headers={file_originalFile=d:\tmp\2.txt, id=a4f7d240-5a7b-d088-f987-84f0c747afe0, file_name=2.txt, timestamp=1443197586559}] 
[task-scheduler-3] ERROR: org.springframework.integration.handler.LoggingHandler - GenericMessage [payload=1, headers={file_originalFile=d:\tmp\1.txt, id=a6a56195-7ed3-01d7-f52f-d08f9b395165, file_name=1.txt, timestamp=1443197587559}] 
[task-scheduler-2] ERROR: org.springframework.integration.handler.LoggingHandler - GenericMessage [payload=2, headers={file_originalFile=d:\tmp\2.txt, id=68c95abb-b113-34b1-7488-cf56155845a4, file_name=2.txt, timestamp=1443197588559}] 
[task-scheduler-4] ERROR: org.springframework.integration.handler.LoggingHandler - GenericMessage [payload=1, headers={file_originalFile=d:\tmp\1.txt, id=a58cab74-bd45-be4c-d7ee-853df5818cfa, file_name=1.txt, timestamp=1443197589560}] 
[task-scheduler-1] ERROR: org.springframework.integration.handler.LoggingHandler - GenericMessage [payload=2, headers={file_originalFile=d:\tmp\2.txt, id=a9ba0460-6f37-deed-35ce-03149b23f636, file_name=2.txt, timestamp=1443197590559}] 
[task-scheduler-5] ERROR: org.springframework.integration.handler.LoggingHandler - GenericMessage [payload=111111, headers={file_originalFile=d:\tmp\1.txt, id=d6de0d59-1877-e3e8-da21-8f668ec79e72, file_name=1.txt, timestamp=1443197591560}] 
[task-scheduler-3] ERROR: org.springframework.integration.handler.LoggingHandler - GenericMessage [payload=2, headers={file_originalFile=d:\tmp\2.txt, id=23b36d87-0d60-0d7a-c2c7-696cf93680f7, file_name=2.txt, timestamp=1443197592559}] 
[task-scheduler-6] ERROR: org.springframework.integration.handler.LoggingHandler - GenericMessage [payload=111111, headers={file_originalFile=d:\tmp\1.txt, id=98de0104-2837-6ed1-22a3-1f69292ab5af, file_name=1.txt, timestamp=1443197593559}] 
[task-scheduler-2] ERROR: org.springframework.integration.handler.LoggingHandler - GenericMessage [payload=2, headers={file_originalFile=d:\tmp\2.txt, id=d303e0cc-4657-6548-e08e-863b1089528a, file_name=2.txt, timestamp=1443197594559}] 
[task-scheduler-7] ERROR: org.springframework.integration.handler.LoggingHandler - GenericMessage [payload=111111, headers={file_originalFile=d:\tmp\1.txt, id=861ffa79-c76d-8216-1620-da50c53bf83c, file_name=1.txt, timestamp=1443197595560}] 
[task-scheduler-4] ERROR: org.springframework.integration.handler.LoggingHandler - GenericMessage [payload=2, headers={file_originalFile=d:\tmp\2.txt, id=f63680c5-11c7-e303-9338-9dd5028b7bcb, file_name=2.txt, timestamp=1443197596559}] 
[task-scheduler-8] ERROR: org.springframework.integration.handler.LoggingHandler - GenericMessage [payload=111111, headers={file_originalFile=d:\tmp\1.txt, id=7e565984-0dab-6187-5969-2bc9a5104d49, file_name=1.txt, timestamp=1443197597559}] 
[task-scheduler-1] ERROR: org.springframework.integration.handler.LoggingHandler - GenericMessage [payload=2, headers={file_originalFile=d:\tmp\2.txt, id=0ae04d1c-a9c9-1877-2025-248c2f387c5a, file_name=2.txt, timestamp=1443197598559}] 

等。

请注意,我在那里有永久从目录中提取的两个相同的文件,请查找文件1.txt的内容如何更改,并且它也反映在我的应用程序中。

因此,或者你的fileOrderComparator为我们做了一些意想不到的事情。或者你的文件不适合这种模式。

0

谢谢Artem!

这确实是我的 FileOrderComparator使用Map来确定文件的文件名的优先级,所以类似的文件名总是阻止导入。

我正在使用Spring集成版本4.1.2。

相关问题