diff --git a/CHANGELOG.md b/CHANGELOG.md
index 6c61566f..1a88f79c 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -9,4 +9,5 @@
- [feat: support log path configuration parameters.](https://github.com/Tencent/spring-cloud-tencent/pull/1143)
- [feat:add swagger exposure filters.](https://github.com/Tencent/spring-cloud-tencent/pull/1144)
- [feat:add swagger report switch.](https://github.com/Tencent/spring-cloud-tencent/pull/1147)
-- [fix: dynamic routing using cookies.](https://github.com/Tencent/spring-cloud-tencent/pull/1152)
\ No newline at end of file
+- [fix: dynamic routing using cookies.](https://github.com/Tencent/spring-cloud-tencent/pull/1152)
+- [fix:fix retry loadbalancer not working bug.](https://github.com/Tencent/spring-cloud-tencent/pull/1157)
diff --git a/spring-cloud-tencent-examples/polaris-discovery-example/discovery-caller-service/pom.xml b/spring-cloud-tencent-examples/polaris-discovery-example/discovery-caller-service/pom.xml
index 69e5c1e6..f6a28f36 100644
--- a/spring-cloud-tencent-examples/polaris-discovery-example/discovery-caller-service/pom.xml
+++ b/spring-cloud-tencent-examples/polaris-discovery-example/discovery-caller-service/pom.xml
@@ -33,6 +33,11 @@
spring-cloud-starter-tencent-polaris-contract
+
+
+
+
+
diff --git a/spring-cloud-tencent-polaris-loadbalancer/src/main/java/com/tencent/cloud/polaris/loadbalancer/config/PolarisLoadBalancerAutoConfiguration.java b/spring-cloud-tencent-polaris-loadbalancer/src/main/java/com/tencent/cloud/polaris/loadbalancer/config/PolarisLoadBalancerAutoConfiguration.java
index 571afe5a..1a657844 100644
--- a/spring-cloud-tencent-polaris-loadbalancer/src/main/java/com/tencent/cloud/polaris/loadbalancer/config/PolarisLoadBalancerAutoConfiguration.java
+++ b/spring-cloud-tencent-polaris-loadbalancer/src/main/java/com/tencent/cloud/polaris/loadbalancer/config/PolarisLoadBalancerAutoConfiguration.java
@@ -25,11 +25,11 @@ import com.tencent.cloud.rpc.enhancement.resttemplate.EnhancedRestTemplateInterc
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
-import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.cloud.client.loadbalancer.LoadBalancerInterceptor;
import org.springframework.cloud.client.loadbalancer.RestTemplateCustomizer;
+import org.springframework.cloud.client.loadbalancer.RetryLoadBalancerInterceptor;
import org.springframework.cloud.netflix.ribbon.RibbonAutoConfiguration;
import org.springframework.cloud.netflix.ribbon.RibbonClients;
import org.springframework.context.annotation.Bean;
@@ -55,19 +55,23 @@ public class PolarisLoadBalancerAutoConfiguration {
}
@Bean
- @ConditionalOnMissingBean
- public RestTemplateCustomizer restTemplateCustomizer(@Autowired(required = false) LoadBalancerInterceptor loadBalancerInterceptor) {
+ public RestTemplateCustomizer restTemplateCustomizer(
+ @Autowired(required = false) RetryLoadBalancerInterceptor retryLoadBalancerInterceptor,
+ @Autowired(required = false) LoadBalancerInterceptor loadBalancerInterceptor) {
return restTemplate -> {
List list = new ArrayList<>(restTemplate.getInterceptors());
// LoadBalancerInterceptor must invoke before EnhancedRestTemplateInterceptor
- if (loadBalancerInterceptor != null) {
+ if (retryLoadBalancerInterceptor != null || loadBalancerInterceptor != null) {
int addIndex = list.size();
for (int i = 0; i < list.size(); i++) {
if (list.get(i) instanceof EnhancedRestTemplateInterceptor) {
addIndex = i;
}
}
- list.add(addIndex, loadBalancerInterceptor);
+ list.add(addIndex,
+ retryLoadBalancerInterceptor != null
+ ? retryLoadBalancerInterceptor
+ : loadBalancerInterceptor);
}
restTemplate.setInterceptors(list);
};