Home > Mobile >  Retry the call if server is down in JAVA
Retry the call if server is down in JAVA

Time:09-29

I am trying to implement the retry logic or mechanism on micro-services to micro-services call. Basically, have to attempt retry 2 times if server is down only.

I tried to use @Retryable and @Recover to perform same but no luck. Instead I can thought of to use try-catch to catch particular exception when server is down, but I am not aware which exception will work and I can use it in try-catch to attempt retry 2 times when server is down.

Moreover, I checked and hence found for such cases there is ResourceAccessException which basically made for when server is down but I am not sure.

Your help will be most appreciated. Please guide me here.

CodePudding user response:

Spring @Retryable should do the job

https://www.baeldung.com/spring-retry

NB: @EnableRetry is important

CodePudding user response:

You can implement a Circuit Breaker with Spring Boot. Circuit Breakers allow you to manage the error in the event of both a retry and an error.

Here are some Circuit Breakers that you can use with Spring Boot:

  • Related