简体   繁体   English

当使用 Spring 引导 Java 启动 SFTP 远程服务器时如何获得通知?

[英]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.

相关问题 Spring Integration Java DSL SFTP如何在处理程序中获取远程SFTP服务器信息 - Spring Integration Java DSL SFTP how to get remote SFTP server information in handler 在Spring Boot healtcheck状态更改时收到通知 - get notified when spring boot healtcheck status changes 如何使用 Java 将存储在远程 SFTP 服务器中的文件复制到同一远程服务器中的另一个文件夹? - How do I copy files stored in a remote SFTP server to another folder in the same remote server using Java? 如何在不使用 spring 引导的情况下使用 spring 集成从 sftp 服务器下载文件 - how to download file from sftp server using spring integration without using spring boot 如何在使用java with selenium>的网页中出现警报时收到通知 - How to get notified when alert appeared in webpage using java with selenium > 如何使用spring从sftp服务器获取zip文件 - How to get zip files from sftp server using spring Spring Boot WebSocket - 如何在客户端订阅时获得通知 - Spring Boot WebSocket - how to get notified on client subscriptions 使用Spring Integrations Sftp Streaming Java配置写入远程文件 - Writing to a remote file using Spring Integrations Sftp Streaming java configuration 在Java连接上执行自动提交时如何获得通知? - How to get notified when auto-commit is performed on a Java connection? 如何使用Spring Boot执行器获取当前服务器时间戳 - How to get the current server timestamp using spring boot actuator
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM