【发布时间】:2018-08-07 12:57:55
【问题描述】:
我正在使用 spring 集成 sftp 入站流媒体通道适配器,它每隔几秒轮询一次。入站适配器选择同一个文件进行多次处理。下面是配置。
<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);
}
面临的问题是同一个文件正在处理多个文件。处理后文件将保留在同一远程目录中。我的过滤器配置是否有问题有人可以帮我解决这个问题吗?
【问题讨论】:
标签: spring spring-integration spring-integration-sftp