Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spring Cloud: How to use Feign without Ribbon

Tags:

I would like to use Feign without client-side loadbalancer Ribbon because I don't want to run Eureka, which would need to be distributed and highly available. Instead internal ELBs with internal DNS names managed by Route53 will do just fine.

Providing plain URLs to @FeignClient always results in no loadbalancer found for .., so I tried preventing Feign from using Ribbon:

Spring Cloud Netflix comes with FeignRibbonClient, which is used if ILoadBalancer from ribbon-loadbalancer is present. However, if this dependency is excluded FeignConfiguration is broken:

Bean creation exception on FactoryBean type check: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'apiVersionClient': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: feign.codec.Decoder org.springframework.cloud.netflix.feign.FeignConfiguration.decoder; nested exception is java.lang.ArrayStoreException: sun.reflect.annotation.TypeNotPresentExceptionProxy 

Ideas welcome :-)

like image 956
Konrad Hosemann Avatar asked Dec 23 '14 12:12

Konrad Hosemann


People also ask

Does feign use ribbon?

Ribbon is a client side load balancer which gives you a lot of control over the behaviour of HTTP and TCP clients. Feign already uses Ribbon, so if you are using @FeignClient then this section also applies. A central concept in Ribbon is that of the named client.

Can we use feign client without Eureka?

Yes you can use Feign without Ribbon, All you need to do is specify the base url in your Feign Java interface class.

Does spring cloud gateway use ribbon?

Spring Cloud still supports Netflix Ribbon, but Netflix Ribbons days are numbered, like so much else of the Netflix microservices stack, so we've provided an abstraction to support an alternative.

Does Zuul use ribbon?

Internally, Zuul uses Netflix Ribbon to look up for all instances of the service from the service discovery (Eureka Server).


1 Answers

If you want to use a plain URL use:

@FeignClient(value = "http://example.com", loadbalance = false) 

With the Brixton release train you would use:

@FeignClient(url = "http://example.com", name = "example") 
like image 53
spencergibb Avatar answered Sep 22 '22 06:09

spencergibb