Spring 集成流登录出站成功

Spring Integration Flow Log on Outbound success

如果文件传输成功,如何添加日志。 我想从我的 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() 频道。 Docs here.

            .publishSubscribeChannel(s -> s
                    .subscribe(f -> f
                            .handle(...)
                    .subscribe(f -> f
                            .log())