首页 文章

Spring Integration Sftp Streaming入站通道适配器多次处理相同的文件

提问于
浏览
2

我正在使用spring integration sftp inbound流媒体通道适配器,每隔几秒轮询一次 . 入站适配器正在选择相同的文件以进行多次处理 . 以下是配置 .

<int-sftp:inbound-streaming-channel-adapter id="ftpInbound"
        channel="ftpChannel"
        session-factory="sessionFactory"
        filter="filter"
        remote-file-separator="/"
        remote-directory="/sampleFolder" auto-startup="true">
    <int:poller fixed-rate="30000" max-messages-per-poll="1" />
</int-sftp:inbound-streaming-channel-adapter>



<int:stream-transformer id="withCharset" charset="UTF-8"
input-channel="ftpChannel" output-channel="outputChannel"/> 

<bean id="filter"
class="org.springframework.integration.file.filters.CompositeFileListFilter">
<constructor-arg>
    <list>
        <bean
            class="sample.CustomFilter">

</bean>
         <bean
class="org.springframework.integration.file.filters. 
AcceptOnceFileListFilter"/>
    </list>
</constructor-arg>

上面代码中的sample.CustomFilter是SftpRegexPatternFileListFilter的子类,其中我按照下面的方法修改了accept方法,只接受名称中当前日期的文件,按照Spring SFTP varying filename-regex中的解决方案

public boolean accept(ChannelSftp.LsEntry file){
setPattern(new java.text.SimpleFormat("yyyyMMDD").format(new 
java.util.Date())+".txt$"
super.accept(file);
}

面临的问题是处理多个文件的同一文件 . 处理完成后,文件将保留在同一个远程目录中 . 我的过滤器配置是否存在问题有人可以帮我解决这个问题 .

1 回答

相关问题