【问题标题】:Spring integration with ftp skip filesSpring 与 ftp 跳过文件的集成
【发布时间】:2015-06-24 07:20:57
【问题描述】:

我正在使用 spring 集成从 ftp 连接和下载文件。 我有两个过滤器,一个按文件名,另一个只接受一个使用 redis 的文件。 在大多数情况下,它的效果很好,但我注意到两个问题:

  1. 有些文件被跳过,根本没有下载
  2. 一些文件正在开始写入,但在完成之前停止并以 .writing 临时文件扩展名离开 - 我怀疑当我重新启动服务或与 ftp 服务器的连接丢失时会发生这种情况。

以下是我的 sftp 连接配置,但我还有两个供应商,一个使用 ftp,另一个 ftp 有同样的问题。

<bean id="eeSftpClientFactory" class="org.springframework.integration.sftp.session.DefaultSftpSessionFactory">
    <property name="host" value="ftp.host.com"/>
    <property name="port" value="22"/>
    <property name="user" value="myUserName"/>
    <property name="password" value="myPassword"/>
</bean>

<bean id="eeFilesFilter" class="org.springframework.integration.file.filters.CompositeFileListFilter">
    <constructor-arg>
        <list>
            <bean class="org.springframework.integration.sftp.filters.SftpPersistentAcceptOnceFileListFilter">
                <constructor-arg ref="redisMetadataStore"/>
                <constructor-arg value=""/>
            </bean>
            <bean class="org.springframework.integration.sftp.filters.SftpSimplePatternFileListFilter">
                <constructor-arg value="*.nm4"/>
            </bean>
        </list>
    </constructor-arg>
</bean>

<int-sftp:inbound-channel-adapter id="eeChannelAdapter"
                                 channel="eeFtpChannel"
                                 session-factory="eeSftpClientFactory"
                                 auto-startup="${ais.feeds.ee.enabled}"
                                 auto-create-local-directory="true"
                                 delete-remote-files="false"
                                 remote-directory="/SAISData/"
                                  filter="eeFilesFilter"
                                 local-directory="${ais.feeds.base.path}/eeVendor">
    <int:poller fixed-delay="500" max-messages-per-poll="-1"/>
</int-sftp:inbound-channel-adapter>

<int:channel id="eeFtpChannel">
    <int:queue capacity="500"/>
</int:channel>

<int:service-activator id="eeFeedHandlerActivator"
                       input-channel="eeFtpChannel"
                       ref="eeFeedHandler"
                       method="execute">
    <int:poller fixed-delay="500" max-messages-per-poll="-1"/>
</int:service-activator>

非常感谢您的建议!

【问题讨论】:

    标签: java spring ftp spring-integration


    【解决方案1】:

    找到问题 #2 的原因 - SftpPersistentAcceptOnceFileListFilter 检查文件是否已被处理并将其添加到元数据存储区 - 如果进程因重新启动而在中间停止,则文件不会从元数据存储区回滚,因此在重新启动后再次检查时文件已存在于元数据中存储,因此不会重新下载。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-02-26
      • 1970-01-01
      • 2020-04-21
      • 1970-01-01
      • 1970-01-01
      • 2013-02-04
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多