【问题标题】:spring integration sftp:inbound-channel-adapter delete-remote-files=falsespring 集成 sftp:inbound-channel-adapter delete-remote-files=false
【发布时间】:2015-05-22 14:25:12
【问题描述】:

我们正在使用 spring 集成 sftp:inbound-channel-adapter 从远程主机传输数据。我们希望将文件保留在远程主机上。因此我们尝试了 delete-remote-files=false 选项。

<int-sftp:inbound-channel-adapter 
    id="sftpInboundChannelAdapter"
    channel="filesToParse"  
    session-factory="..."
    remote-directory="..." 
    filename-pattern="..." 
    local-directory="..." 
    temporary-file-suffix=".tmp" 
    delete-remote-files="false" 
    auto-create-local-directory="true" local-filter="localFileFilter"
>

不幸的是,这些文件随后会被处理多次。有没有办法保留远程文件而不是多次处理它们?

编辑:这是因为后续进程会在本地删除文件。

    <bean id="localFileFilter" class="org.springframework.integration.file.filters.AcceptAllFileListFilter"/>

【问题讨论】:

    标签: java spring spring-integration


    【解决方案1】:

    注意AcceptOnceFileListFilter(实际上是默认值)只会防止当前执行的重复;它将其状态保存在内存中。

    为避免在执行过程中出现重复,您应该使用配置了适当元数据存储的FileSystemPersistentAcceptOnceFileListFilter

    请注意,PropertiesPersistingMetadataStore 仅在正常的应用程序上下文关闭(关闭)时将其状态保存到磁盘,因此最强大的解决方案是 Redis 或 MongoDB(或您自己的 ConcurrentMetadataStore 实现)。

    您也可以不时(或在流程中)在PropertiesPersistingMetadataStore 上致电flush()

    【讨论】:

      【解决方案2】:

      我更改了过滤器:它现在只检索一次。

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

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2016-11-26
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2016-11-11
        • 1970-01-01
        • 2016-01-27
        • 2014-12-24
        相关资源
        最近更新 更多