使用入站通道适配器从ftp服务器获取文件更新

时间:2016-08-03 13:10:48

标签: java spring ftp spring-integration

我正在尝试从ftp服务器获取文件更新(如果添加了任何新文件)但代码是通过创建给定名称的新文件夹从本地目录获取文件更新

@Bean
public FtpInboundFileSynchronizer ftpInboundFileSynchronizer() {
    FtpInboundFileSynchronizer fileSynchronizer = 
            new FtpInboundFileSynchronizer(ftpSessionFactory());
    fileSynchronizer.setDeleteRemoteFiles(false);
    fileSynchronizer.setRemoteDirectory("/");
    fileSynchronizer.setRemoteFileSeparator("/");
    fileSynchronizer.setFilter(new FtpSimplePatternFileListFilter("*"));
    return fileSynchronizer;
}



    @Bean
    @InboundChannelAdapter(channel = "ftpChannel")
    public MessageSource<File> ftpMessageSource() {
        FtpInboundFileSynchronizingMessageSource source =
                new FtpInboundFileSynchronizingMessageSource(fileSynchronizer);
        source.setLocalDirectory(new File("/FTP_Test"));
        source.setAutoCreateLocalDirectory(true);
        source.setLocalFilter(new AcceptOnceFileListFilter<File>());
        return source;
    }
private SessionFactory<FTPFile> ftpSessionFactory() {
    DefaultFtpSessionFactory sf = new DefaultFtpSessionFactory();
    sf.setHost(host);
    sf.setPort(port);
    sf.setUsername(username);
    sf.setPassword(password); 
    return new CachingSessionFactory<FTPFile>(sf);
}

我做错了什么

0 个答案:

没有答案