[英]How to get notified when SFTP Remote Server is UP using Spring Boot Java?
I am working on a scenario, where the SFTP remote server is down for an hour or more.我正在处理一个 SFTP 远程服务器停机一个小时或更长时间的场景。 How do I get notified when the remote server is up again so that I can SFTP files as soon as it is back to an active state.如何在远程服务器再次启动时收到通知,以便我可以在它回到活动的 state 后立即对文件进行 SFTP。 Currently, I am using Spring integration sftp, and spring-boot java f/w.目前,我正在使用 Spring 集成 sftp 和 spring-boot java f/w。 Are there any built-in methods I can use?我可以使用任何内置方法吗?
I'm not sure if such a question is correct at all: the SFTP server ia passive service: you call it, no opposite.我不确定这样的问题是否正确:SFTP 服务器 ia 被动服务:你称之为,没有相反的意思。 Therefore I doubt there is such a feature in any SFTP vendors like send notifications about its lifecycle.因此,我怀疑任何 SFTP 供应商都有这样的功能,比如发送有关其生命周期的通知。
You can ping the server periodically with a DefaultSftpSessionFactory.getSession()
.您可以使用DefaultSftpSessionFactory.getSession()
定期 ping 服务器。 It checks for the connection and tries to reconnect otherwise.它检查连接并尝试重新连接。
Another solution is to use a RequestHandlerRetryAdvice
on your SftpMessageHandler
to retry sending the file for some number of attempts with some backoff in between.另一种解决方案是在您的SftpMessageHandler
上使用RequestHandlerRetryAdvice
来重试发送文件以进行一些尝试,并在两者之间进行一些退避。
See more in docs: https://docs.spring.io/spring-integration/docs/current/reference/html/messaging-endpoints.html#retry-advice在文档中查看更多信息: https://docs.spring.io/spring-integration/docs/current/reference/html/messaging-endpoints.html#retry-advice
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.