gpt4 book ai didi

java - 如何阻止处理 `int-ftp:inbound-channel-adapter ` 中的旧文件?

转载 作者:行者123 更新时间:2023-11-30 03:03:28 25 4
gpt4 key购买 nike

感谢关注
我在Spring集成中使用了int-ftp:inbound-channel-adapter,我想从ftp服务器检索文件并对其进行处理,并将备份保存在本地目录中,但是当应用程序处于启动状态时int-ftp:inbound-channel-adapter 从备份位置中的本地旧文件创建消息,并尝试发送到 channel 我的代码,如下所示:

 <bean id="acceptOnceFilter"
class="org.springframework.integration.file.filters.AcceptOnceFileListFilter" />

<int-ftp:inbound-channel-adapter id="sam-inbound-channel-adapter"
channel="sam-ready-to-process-inbound"
session-factory="sam-ftp-Session"
auto-create-local-directory="true"
delete-remote-files="true"
auto-startup="true"
filename-pattern="*.bmp"
remote-directory="/in/"
remote-file-separator="/"
local-filter="acceptOnceFilter"
preserve-timestamp="true"
local-filename-generator-expression="@fileName.name('sam',#this)"
temporary-file-suffix=".writing"
local-directory="./backup/sam/in//">
<int:poller fixed-rate="10000"/>
</int-ftp:inbound-channel-adapter>

提前致谢

最佳答案

see the documentation 。您可以在 local-filter 中使用 FileSystemPersistentAcceptOnceFileListFilter 以及您选择的 MetadataStore,以防止文件在重新启动后被重新处理。

但是,通常最好在处理后删除/重命名文件;否则,随着时间的推移,随着本地目录中必须扫描的文件数量的增加,性能将会下降。

由于您要删除远程文件,因此不需要它,但是(为了完整性)还有一个 FtpPersistentAcceptOnceFileListFilter (在 filter 中)来防止重新删除重新启动后获取文件(当 delete-remote-files 为 false 时需要)。

关于java - 如何阻止处理 `int-ftp:inbound-channel-adapter ` 中的旧文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35376950/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com