Reputation: 19
how can I add logs if file is transferred successfully.
I want to log file name and some values form my config
object
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();
Update after Gary Russell answer, my working code is
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();
Upvotes: 0
Views: 687
Reputation: 174554
Add a .publishSubscribeChannel()
channel with 2 subflows. Docs here.
.publishSubscribeChannel(s -> s
.subscribe(f -> f
.handle(...)
.subscribe(f -> f
.log())
Upvotes: 2