spring-cloud-openfeign icon indicating copy to clipboard operation
spring-cloud-openfeign copied to clipboard

Hystrix fallback does not work with spring-cloud load balancer

Open gbtec-valerierinke opened this issue 5 years ago • 2 comments
trafficstars

We are using hystrix fallback with a feign client for preventing errors when a service is not available.

Now we upgrade spring cloud to HOXTON.SR3 and found this note

BlockingLoadBalancerClientRibbonWarnLogger : You already have RibbonLoadBalancerClient on your classpath. It will be used by default. As Spring Cloud Ribbon is in maintenance mode. We recommend switching to BlockingLoadBalancerClient instead. In order to use it, set the value of spring.cloud.loadbalancer.ribbon.enabled to false or remove spring-cloud-starter-netflix-ribbon from your project.

So we change the project as follows:

  • set spring.cloud.loadbalancer.ribbon.enabled to false
  • exclude the ribbon loadbalancer from class path
<dependency>
           <groupId>org.springframework.cloud</groupId>
           <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>org.springframework.cloud</groupId>
                    <artifactId>spring-cloud-starter-ribbon</artifactId>
               </exclusion>
               <exclusion>
                    <groupId>com.netflix.ribbon</groupId>
                    <artifactId>ribbon-eureka</artifactId>
                </exclusion>
            </exclusions>
</dependency>
  • add spring-cloud-starter-loadbalancer dependency

Now the hystrix fallback implementation is not called anymore and we see this warning in the log:

2020-03-25 10:40:28.799  WARN 16340 --- [oundedElastic-1] o.s.c.l.core.RoundRobinLoadBalancer      : No servers available for service: xxx-service
2020-03-25 10:40:28.801  WARN 16340 --- [o-auto-1-exec-1] .s.c.o.l.FeignBlockingLoadBalancerClient : Load balancer does not contain an instance for the service xxx-service

gbtec-valerierinke avatar Mar 25 '20 09:03 gbtec-valerierinke

The exclusion is optional and maybe that's what's removed Hystrix from classpath. Can you just set spring.cloud.loadbalancer.ribbon.enabled to false without excluding the dependency and verify if the issue is still there?

OlgaMaciaszek avatar Mar 27 '20 10:03 OlgaMaciaszek

Our first try was only setting the flag to false. The same issue then.

gbtec-valerierinke avatar Mar 30 '20 05:03 gbtec-valerierinke

Closing as the issue concerns versions that are no longer supported.

OlgaMaciaszek avatar Mar 09 '23 13:03 OlgaMaciaszek