简体   繁体   中英

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. 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. Currently, I am using Spring integration sftp, and 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. Therefore I doubt there is such a feature in any SFTP vendors like send notifications about its lifecycle.

You can ping the server periodically with a DefaultSftpSessionFactory.getSession() . 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.

See more in docs: https://docs.spring.io/spring-integration/docs/current/reference/html/messaging-endpoints.html#retry-advice

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM