2

We're using openfeign client in our spring application:

<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-openfeign-core</artifactId>
    <version>3.0.1</version>
</dependency>
<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-openfeign</artifactId>
    <version>3.0.1</version>
</dependency>

and we're also using netflix zuul:

<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-netflix-zuul</artifactId>
    <version>2.2.6.RELEASE</version>
</dependency>

the problem now is that netflix-zuul requires spring-cloud-netflix-ribbon as a dependency, which makes the feignclient use the ribbon load balancer which throws an error because it's incompatible with the newest spring version: org.springframework.cloud.netflix.ribbon.RibbonLoadBalancerClient cannot be cast to class org.springframework.cloud.loadbalancer.blocking.client.BlockingLoadBalancerClient.

according to https://cloud.spring.io/spring-cloud-static/spring-cloud-openfeign/2.2.0.RC2/reference/html/ the Spring load balancer should be used:

In order to maintain backward compatibility, is used as the default load-balancer implementation. However, Spring Cloud Netflix Ribbon is now in maintenance mode, so we recommend using Spring Cloud LoadBalancer instead. To do this, set the value of spring.cloud.loadbalancer.ribbon.enabled to false.

So tried to disable ribbon in the configuration yml but it's not working, feignclient is still using ribbon:

spring:
    cloud:
        loadbalancer:
            ribbon:
                enabled: false

I found another answer here: https://stackoverflow.com/a/51511614/1264616, which says that you need to define the bean for the client in the feign configuration like this:

@Bean
public Client feignClient() {
    return new Client.Default(null, null);
}

I did that and it is working now, however I've no idea what this default client actually does and if it will break some of the configuration etc... so I'm really not sure if that's a solution or not. I'm also wondering, why the spring configuration spring.cloud.loadbalancer.ribbon.enabled=false does not do anything at all.

Perhaps I need to wait for an zuul update (which might not happen)?

I'm using spring cloud 2020.0.1 and spring boot 2.4.2

Sepultura
  • 997
  • 1
  • 9
  • 28
  • 1
    mixing 3.x and 2.x versions is not supported. – spencergibb Feb 04 '21 at 16:10
  • I see, but 2.2.6.RELEASE is the newest version - hopefully they will provide an update, not sure if we can get rid of zuul :( – Sepultura Feb 04 '21 at 16:14
  • Zuul 1 is no longer maintained by Netflix and has been removed from spring cloud 2020.0 (versions 3.0.x) – spencergibb Feb 05 '21 at 14:06
  • I now, but we’re using zuul in our project. since zuul includes ribbon as dependency, feign client is using ribbon too (which leads to the error above). this should be solved by disabling ribbon in the configuration but for some reason it’s not working, feign is still uslng ribbon although I disabled it. seems like the only solution is to complete remove zuul from our project – Sepultura Feb 05 '21 at 14:16
  • 1
    If you want to use boot 2.4 and Spring Cloud 2020.0, then yes. Spring Cloud gateway is our replacement. – spencergibb Feb 05 '21 at 15:20
  • how do you migrate from zuul to spring cloud gateway? any guidance? – ahunigel Jul 23 '21 at 05:37
  • were you able to figure this out? – theprogrammer Apr 04 '22 at 14:00

0 Answers0