0

I'm using Spring Boot 2.3.3 along with Spring Retry 1.2.5.

We're replacing usages of Ribbon with Spring Cloud Load Balancer. One of the bits of functionality that I can't get to work is setting the max retries of our RestTemplates. In the old code we have these properties set:

client.ribbon.MaxAutoRetries: 2

client.ribbon.MaxAutoRetriesNextServer: 3

The documentation for for Spring Cloud Commons, Retrying Failed Requests indicates:

"The load-balanced RestTemplate honors some of the Ribbon configuration values related to retrying failed requests. You can use client.ribbon.MaxAutoRetries, client.ribbon.MaxAutoRetriesNextServer, and client.ribbon.OkToRetryOnAllOperations properties."

https://docs.spring.io/spring-cloud-commons/docs/2.2.4.RELEASE/reference/html/#retrying-failed-requests

  • I have Spring Retry added to my maven POM
  • I have @EnableRetry annotation on the Application startup class
  • I have the settings for MaxAutoRetries and MaxAutoRetriesNextServer set in the application.yml
  • I have RestTemplate bean defined with the @LoadBalanced annotation
  • The code works when all the services are running

When I shut down one of the services the RestTemplate is calling, the RestTemplate doesn't attempt to make the call multiple times as it's configured. I'm specifically interested in the MaxAutoRetriesNextServer as that's the most important bit.

Question 1:

What else do I need to do to get Spring Retry to make the RestTemplate retry, and retry on the next server etc.?

Question 2:

Why is the MaxAutoRetriesNextServer property not exposed on the Spring Retry api? I only see a property for setMaxAttempts in the SimpleRetryPolicy.

  • Spring Cloud Netflix Ribbon is no longer supported. Please use Spring Cloud LoadBalancer instead. – OlgaMaciaszek Jun 27 '22 at 12:36
  • 1
    @OlgaMaciaszek That's why I said we were transitioning from Ribbon to SCLB in my second sentence :) Upgrading to newer boot/cloud version fixed the issue using the newer version of those settings worked. Everything is working as it should now...thanks for all your hard work on these Spring projects! – CoffeeCupDeveloper Jun 28 '22 at 18:36

0 Answers0