首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >FtpInboundFileSynchronizer.setDeleteRemoteFiles(true)传输后不删除远程文件

问FtpInboundFileSynchronizer.setDeleteRemoteFiles(true)传输后不删除远程文件
EN

Stack Overflow用户
提问于 2016-12-29 00:24:57
回答 1查看 596关注 0票数 1

我正在尝试spring boot,集成ftp示例(http://docs.spring.io/spring-integration/reference/html/ftp.html,15.5.1 )。我能够从远程目录中读取文件,有些是如何不使用标志setDeleteRemoteFiles(true)来删除文件的。如果我没有设置任何标志来删除远程文件,请让我知道。

代码语言:javascript
复制
@Bean
public SessionFactory<FTPFile> ftpSessionFactory() {
    DefaultFtpSessionFactory sf = new DefaultFtpSessionFactory();
    sf.setHost("localhost");
    sf.setPort(21);
    sf.setUsername("sudaredd");
    sf.setPassword("");
    return new CachingSessionFactory<FTPFile>(sf);
}

 @Bean
    public FtpInboundFileSynchronizer ftpInboundFileSynchronizer() {
        FtpInboundFileSynchronizer fileSynchronizer = new FtpInboundFileSynchronizer(ftpSessionFactory());
        fileSynchronizer.setDeleteRemoteFiles(true);
        fileSynchronizer.setRemoteDirectory("");
        fileSynchronizer.setFilter(new FtpSimplePatternFileListFilter("*"));
        return fileSynchronizer;
    }
  @Bean
    @InboundChannelAdapter(channel = "ftpChannel", poller = @Poller(fixedDelay = "5000"))
    public MessageSource<File> ftpMessageSource() {
        FtpInboundFileSynchronizingMessageSource source =
                new FtpInboundFileSynchronizingMessageSource(ftpInboundFileSynchronizer());
        source.setLocalDirectory(new File("ftp-inbound"));
        source.setAutoCreateLocalDirectory(true);
        source.setLocalFilter(new AcceptOnceFileListFilter<File>());
        return source;
    }
EN

回答 1

Stack Overflow用户

发布于 2016-12-29 01:34:03

所有的配置看起来都很好。

尝试打开org.springframework.integration类别的DEBUG以跟踪行为。

OTOH,请确保您的FTP服务器支持删除操作,并且您的用户确实有权限执行该操作。

由于@InboundChannelAdapter通过taskScheduler执行其任务,因此您可能会遗漏日志中的一个错误。

如果您能够调试代码并在AbstractInboundFileSynchronizer.copyFileToLocalDirectory()中放置断点,以便遵循逻辑并确定可能的错误,那也是非常好的。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/41365993

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档