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."
- 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.