如何解决从一个 SFTP 读取具有 3 种不同命名模式的文件并在 Spring 应用程序中进行不同的处理
我有一个 SFTP 位置,spring 应用程序需要读取该位置,并且根据文件名,每种命名模式的业务逻辑都不同。在应用程序中,我使用 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"/>
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。