如何触发和轮询 ftp 出站网关

发布于 2025-01-14 20:42:21 字数 942 浏览 4 评论 0原文

我正在尝试使用递归方法的 ftp 出站网关从 ftp 服务器传输文件,因为我的 ftp 服务器将生成新的随机名称文件夹,并且我需要获取所有内容。我只知道这种方法有效,除非有人可以建议更简单的方法。无论如何,这是我的代码。

@Bean(value = "ftpTolocal")
public IntegrationFlow fileToFile() {
    IntegrationFlow flow = IntegrationFlows
            .from("inputChannel")
            .handle(Ftp.outboundGateway(defaultFtpSessionFactory(),
                    AbstractRemoteFileOutboundGateway.Command.MGET,
                    null)
                    //.regexFileNameFilter("(.*n.txt)")
                    .autoCreateDirectory(true)
                    .options(AbstractRemoteFileOutboundGateway.Option.RECURSIVE)
                    .localDirectoryExpression("'/localDirectory/' + #remoteDirectory"))
            .channel("nullChannel")
            
            .get();
    return flow;
}

我进行了搜索,我总是得到的答案是创建一条 inputChannel 消息,但我找不到真正告诉我如何执行此操作的消息。我也看到了很多xml解决方案,但我找不到如何实现它。 FTP集成指南似乎很少见,而且对于像我这样的菜鸟来说,解释似乎很难理解。提前致谢。

I am trying to transfer files from an ftp server using the ftp outbound gateway with recursive method as my ftp server will generate new random name folder and I need to fetch everything. I only know this method work, unless anyone can suggest easier one. Anyway, this is my code.

@Bean(value = "ftpTolocal")
public IntegrationFlow fileToFile() {
    IntegrationFlow flow = IntegrationFlows
            .from("inputChannel")
            .handle(Ftp.outboundGateway(defaultFtpSessionFactory(),
                    AbstractRemoteFileOutboundGateway.Command.MGET,
                    null)
                    //.regexFileNameFilter("(.*n.txt)")
                    .autoCreateDirectory(true)
                    .options(AbstractRemoteFileOutboundGateway.Option.RECURSIVE)
                    .localDirectoryExpression("'/localDirectory/' + #remoteDirectory"))
            .channel("nullChannel")
            
            .get();
    return flow;
}

I have searched and the answer I always get is to create an inputChannel message but I couldn't find one that actually tells me how to do it. I also see many xml solution, but I couldn't find how to implement it. FTP integration guide seems rare and the explanation seems difficult to understand for a rookie like me. Thanks in advance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

陌伤浅笑 2025-01-21 20:42:21
@Bean
IntegrationFlow polled() {
    return IntegrationFlows.fromSupplier(() -> "testMessage",
                    e -> e.poller(Pollers.fixedDelay(Duration.ofSeconds(5))))
            .handle(System.out::println)
            .get();
}
@Bean
IntegrationFlow polled() {
    return IntegrationFlows.fromSupplier(() -> "testMessage",
                    e -> e.poller(Pollers.fixedDelay(Duration.ofSeconds(5))))
            .handle(System.out::println)
            .get();
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文