Spring 未找到文件时的集成流日志记录
Spring Integration Flow Logging When No File Found
我已经有一个工作 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 但只有在它在服务器上找到文件时才会触发。
虽然问题 来自另一个用户,但看起来你们都在谈论同一个项目和同一个问题。
我无法关闭你的问题,因为我的答案还没有投票,所以我也 copy/paste 我的答案在这里。
Sftp.inboundAdapter(inboundSftp)
是一个SourcePollingChannelAdapter
基于轮询器配置的定时任务。如果没有来自源的数据来构建消息,它实际上不会在 outputChannel
中生成任何内容。但关键是触发器上的任务仍在执行,我们有一些钩子如何捕捉那个阶段。
为此,我们有一个 AbstractMessageSourceAdvice
组件用于其 afterReceive()
实施。这是您可以执行 "Empty Remote Directory" 逻辑的地方。这样的 Advice
然后必须注入 poller(Pollers...advice())
.
在文档中查看更多信息:https://docs.spring.io/spring-integration/docs/5.3.0.M4/reference/html/core.html#conditional-pollers
我已经有一个工作 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 但只有在它在服务器上找到文件时才会触发。
虽然问题
我无法关闭你的问题,因为我的答案还没有投票,所以我也 copy/paste 我的答案在这里。
Sftp.inboundAdapter(inboundSftp)
是一个SourcePollingChannelAdapter
基于轮询器配置的定时任务。如果没有来自源的数据来构建消息,它实际上不会在 outputChannel
中生成任何内容。但关键是触发器上的任务仍在执行,我们有一些钩子如何捕捉那个阶段。
为此,我们有一个 AbstractMessageSourceAdvice
组件用于其 afterReceive()
实施。这是您可以执行 "Empty Remote Directory" 逻辑的地方。这样的 Advice
然后必须注入 poller(Pollers...advice())
.
在文档中查看更多信息:https://docs.spring.io/spring-integration/docs/5.3.0.M4/reference/html/core.html#conditional-pollers