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 :-)
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.
Yes you can use Feign without Ribbon, All you need to do is specify the base url in your Feign Java interface class.
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.
Internally, Zuul uses Netflix Ribbon to look up for all instances of the service from the service discovery (Eureka Server).
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")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With