Spring integration 出站成功时的Spring集成流日志
如果文件传输成功,如何添加日志。 我想将文件名和一些值记录到我的Spring integration 出站成功时的Spring集成流日志,spring-integration,spring-integration-dsl,spring-integration-sftp,Spring Integration,Spring Integration Dsl,Spring Integration Sftp,如果文件传输成功,如何添加日志。 我想将文件名和一些值记录到我的config对象中 return IntegrationFlows.from(Sftp.inboundAdapter(inboundSftp) .localDirectory(this.getlocalDirectory(config.getId())) .deleteRemoteFiles(true) .autoCreateLocalDirectory(tru
config
对象中
return IntegrationFlows.from(Sftp.inboundAdapter(inboundSftp)
.localDirectory(this.getlocalDirectory(config.getId()))
.deleteRemoteFiles(true)
.autoCreateLocalDirectory(true)
.remoteDirectory(config.getInboundDirectory()), e -> e.poller(Pollers.cron("0 */1 * ? * *").errorChannel(MessageHeaders.ERROR_CHANNEL).errorHandler((ex) -> {
try {
// exception handling here
})))
.handle(Sftp.outboundAdapter(outboundSftp)
.useTemporaryFileName(false)
.autoCreateDirectory(true)
.remoteDirectory(config.getOutboundDirectory()), c -> c.advice(startup.deleteFileAdvice())
)
.get();
更新
在Gary Russell回答之后,我的工作代码是
return IntegrationFlows.from(Sftp.inboundAdapter(inboundSftp)
.localDirectory(this.getlocalDirectory(config.getId()))
.deleteRemoteFiles(true)
.autoCreateLocalDirectory(true)
.remoteDirectory(config.getInboundDirectory()), e -> e.poller(Pollers.cron("0 */1 * ? * *").errorChannel(MessageHeaders.ERROR_CHANNEL).errorHandler((ex) -> {
// action on exceptions are here
}))).publishSubscribeChannel(s -> s
.subscribe(f -> f
.handle(Sftp.outboundAdapter(outboundSftp)
.useTemporaryFileName(false)
.autoCreateDirectory(true)
.remoteDirectory(config.getOutboundDirectory()), c -> c.advice(startup.deleteFileAdvice())
))
.subscribe(f -> f
.handle(m -> {
// all my custom logging logic is here
})
))
.get();
添加一个带有2个子流的
.publishSubscribeChannel()
频道
添加一个带有2个子流的
.publishSubscribeChannel()
频道
但是对于这个用例,我们需要让这两个订阅者同步并且一个接一个。因此,如果第一个日志中发生故障,则不会调用log的第二个日志。因此,
publishSubscribeChannel()
应该在没有执行器的情况下进行配置。如果我在poller里每一小时给cron一次。它将在数小时后拾取所有文件,并仅传输一个文件而不是所有文件。每小时传输一个文件。我想检查出站cron,但我不确定是否可能,请不要在对旧答案的评论中提出新问题;它不能帮助人们找到问题/答案;你应该总是问一个新问题。您需要在轮询器上增加maxMessagesPerPoll
(默认值为1)。但是对于这个用例,我们需要让这两个订阅服务器同步并逐个进行。因此,如果第一个日志中发生故障,则不会调用log的第二个日志。因此,publishSubscribeChannel()
应该在没有执行器的情况下进行配置。如果我在poller里每一小时给cron一次。它将在数小时后拾取所有文件,并仅传输一个文件而不是所有文件。每小时传输一个文件。我想检查出站cron,但我不确定是否可能,请不要在对旧答案的评论中提出新问题;它不能帮助人们找到问题/答案;你应该总是问一个新问题。您需要在轮询器上增加maxMessagesPerPoll
(默认为1)。
.publishSubscribeChannel(s -> s
.subscribe(f -> f
.handle(...)
.subscribe(f -> f
.log())