我正在使用Spring Boot 2.3.3以及弹簧重试1.2.5。
我们正在用弹簧云负载平衡器替换色带的用法。我无法工作的功能之一是设置我们的rettemplates的最大重试。在旧代码中,我们具有以下属性集:
client.ribbon.maxautories:2
client.ribbon.ribbon.maxautoretriesnextserver:3
春季云共享的文档:
“负载平衡的RESTTEMPLATE尊重与重试失败请求有关的一些功能区配置值。您可以使用client.ribbon.maxautoreties,client.ribbon.maxautoriesnextserver和client.ribbon.ribbon.ribbon.oktoretreetreetryonaryarnallallaserations属性。”
- 我已经添加了弹簧重演,添加到了我的to pom中,
- 我有@enableretry notation in @enableRetry注释应用程序启动类
- MaxautorTies和MaxautorTiesNextServer设置的设置
- I具有
- 。
应用程序中的 RESTTEMPLATE不会在配置时尝试多次进行呼叫。我对MaxautorTiesNextServer特别感兴趣,因为这是最重要的。
问题1:
我还需要做些什么才能让春季重试以进行rettemplate重试,并在下一个服务器等上重试?
问题2:
为什么在春季重试API上未暴露出MaxautorTementserver属性?我只在SimpleRetrypolicy中看到了SetMaxAttEmpt的属性。
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.
发布评论