2
我已经定义了一个ftp:入站通道适配器,它将被作业和自定义过滤器触发,该过滤器检查文件名是否匹配模式,它以前没有处理特定的工作。将作业参数传递到弹簧集成过滤器ftp:入站通道适配器
所以这需要作业名称可供FTP过滤器使用。有没有办法将其传递给过滤器?还有一种方法可以将jobname作为头添加到由ftp适配器发出的消息中?
<int-ftp:inbound-channel-adapter
local-directory="${data.dir}" session-factory="ftpClientFactory"
channel="ftpOutputChannel" remote-directory="${ftp.data.directory}"
filter="ftpFilter">
<int:poller fixed-rate="50000" />
<!--This will be replaced by a trigger job -->
</int-ftp:inbound-channel-adapter>
<beans:bean class="com.example.ftp.FtpFilter"
id="ftpFilter"></beans:bean>
com.example.ftp.FtpFilter
public class FtpFilter implements FileListFilter<FTPFile> {
public List<FTPFile> filterFiles(FTPFile[] files) {
String validRegex = FileFilterStrategy.getValidTarGzRegex();
for (FTPFile file : files) {
String name = file.getName();
if(name.matches(validRegex) && !isProcessed(jobName, name)){
retval.add(file);
}
}
return retval ;
}
}
但是过滤器在不同的作业之间共享,所以设置属性不是一个选项。顺便说一句ls/mget如何给予更多的控制......我们可以列出一个目录并决定使用过滤器获得哪些文件,就像问题一样?虽然会看到出站网关并恢复。 – 2014-09-05 19:01:59
是的,你是绝对正确的,最终使用出站网关和ThreadLocal访问ftpFilter中的作业属性。 – 2014-09-17 12:58:23
@加里,多亏了关注,如何替换现有的文件? – 2015-04-21 09:55:47