【问题标题】:Spring Integration Flow Logging When No File Found找不到文件时的 Spring 集成流日志记录
【发布时间】:2020-04-14 11:18:26
【问题描述】:

我已经有一个工作的IntegrationFlow

IntegrationFlows.from(Sftp.inboundAdapter(inboundSftp)
                .localDirectory(this.getlocalDirectory(config.getId()))
                .deleteRemoteFiles(true)
                .autoCreateLocalDirectory(true)
                .filter(new CompositeFileListFilter().addFilter(new LastModifiedLsEntryFileListFilter(config.getRegexFilter())))
                .remoteDirectory(config.getInboundDirectory())
                , e -> e.poller(Pollers.cron(config.getCron())
                        .errorChannel(MessageHeaders.ERROR_CHANNEL).errorHandler((ex) -> {
               }))).publishSubscribeChannel(s -> s
                .subscribe(f -> {
                    ............
                })
                .subscribe(f -> {
                    .......

                })
                .subscribe(f -> f
                        .......
                ))
                .get();

当源目录上不存在文件时,我正在尝试记录。我尝试使用 LastModifiedLsEntryFileListFilter,但只有在服务器上找到文件时才会触发它。

【问题讨论】:

    标签: spring-integration spring-integration-dsl spring-integration-sftp


    【解决方案1】:

    虽然Spring Integration Flow API does not response when empty remote directory的问题来自另一个用户,但看起来你们都在谈论同一个项目和同一个问题。

    我无法结束你的问题,因为那里还没有对我的答案进行投票,所以我也只是在这里复制/粘贴我的答案。

    Sftp.inboundAdapter(inboundSftp) 是一个基于轮询器配置的计划任务的SourcePollingChannelAdapter。如果没有来自源的数据来构建消息,它实际上不会对outputChannel 产生任何影响。但关键是触发器上的任务仍在执行,我们有一些钩子来捕捉那个阶段。

    为此,我们为其afterReceive() 实现提供了一个AbstractMessageSourceAdvice 组件。这是您可以执行“空远程目录”逻辑的地方。这样的Advice 必须注入poller(Pollers...advice())

    在文档中查看更多信息:https://docs.spring.io/spring-integration/docs/5.3.0.M4/reference/html/core.html#conditional-pollers

    【讨论】:

    • 我对你的回答投了票 :) 你也可以使用出站网关 (LS) 来列出远程文件。
    猜你喜欢
    • 2018-11-23
    • 2015-04-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-06-16
    • 2019-10-16
    • 1970-01-01
    • 2016-07-12
    相关资源
    最近更新 更多