从一个sftp读取具有3种不同命名模式的文件在Spring的应用过程中会有不同的处理方法

cwdobuhd  于 2021-07-13  发布在  Java
关注(0)|答案(0)|浏览(229)

我有一个spring应用程序需要读取的sftp位置,根据文件名,每个命名模式的业务逻辑都是不同的。在应用程序中,我使用echache来消除重复处理。我有3个不同的(每个命名模式1个)相同的实现/配置,如下所示。我面临的问题是文件无法被提取。。不知道我做错了什么。感谢您的帮助。提前谢谢

<!-- Adapters -->
<int-sftp:inbound-channel-adapter id="InboundSftp"
                                  session-factory="sftpSessionFactory"
                                  channel="InboundSftpChannel"

                                  remote-directory="${remoteDirectory}"
                                  delete-remote-files="${deleteRemoteFiles}"
                                  auto-create-local-directory="${autoCreateLocalDir}"
                                  local-directory="${localDirectory}"
                                  preserve-timestamp="1"
                                  local-filter="acceptAllFileListFilter1"
                                  filter="fileFilter1">

    <int:poller fixed-delay="${pollRate}"
                max-messages-per-poll="${maxMessagesPerPoll}"/>
</int-sftp:inbound-channel-adapter>

<!-- Channels -->

<int:channel id="InboundSftpChannel"/>
<int:channel id="ErrorOutboundSftpChannel"/>

<int-sftp:outbound-channel-adapter id="ErrorGateway"
                                   channel="OutboundSftpChannel"
                                   auto-create-directory="${autoCreateLocalDir}"
                                   session-factory="sftpSessionFactory"
                                   remote-directory-expression="headers['directory']"/>

<int:outbound-channel-adapter channel="InboundSftpChannel"
                              ref="Consumer" method="consume"/>

<!-- Beans -->
<bean id="sftpSessionFactory"
      class="org.springframework.integration.sftp.session.DefaultSftpSessionFactory">
    <property name="host" value="${host}"/>
    <property name="port" value="${port}"/>
    <property name="user" value="${username}"/>
    <property name="password" value="${password}"/>
    <property name="allowUnknownKeys" value="true"/>
</bean>

<bean id="Consumer"
      class="com......Consumer">
    <constructor-arg name="errorChannel" ref="OutboundSftpChannel"/>
    <constructor-arg name="errorDirectory" value="${errorRemoteDirectory}"/>
</bean>

<bean id="fileFilter1" class="org.springframework.integration.file.filters.CompositeFileListFilter">
    <constructor-arg name="fileFilters">
        <list>
            <ref bean="fileNamePatternFilter1"/>
            <ref bean="sftpAcceptOnceFilter1"/>
        </list>
    </constructor-arg>
</bean>

<bean id="sftpAcceptOnceFilter1"
      class="org.springframework.integration.sftp.filters.SftpPersistentAcceptOnceFileListFilter">
    <constructor-arg name="prefix" value=""/>
    <constructor-arg name="store" ref="metadataStore1"/>
</bean>

<bean id="fileNamePatternFilter1"
      class="org.springframework.integration.sftp.filters.SftpSimplePatternFileListFilter">
    <constructor-arg name="pattern" value="xyzz**.txt"/>
</bean>

<bean id="metadataStore1" class="com.....MetadataCache">
    <constructor-arg name="cacheManager" ref="cacheManager"/>
</bean>

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

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题