20
votes

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 :-)

2
Why don't you want ribbon-loadbalancer? - spencergibb
I just added some context to the question: It's about Eureka. - Konrad Hosemann
Ribbon does not depend on Eureka. You just have to tell the load balancer where the remote servers are individually (e.g. create a @RibbonClient configuration and set the ServerList up as a @Bean). Which isn't to say that there might not be a bug in Spring Cloud preventing you from doing that easily. - Dave Syer
Ok, I didn't try that. But my point is that I don't want to configure lists of servers, I just want to use a plain URL, as I would do using RestTemplate. - Konrad Hosemann

2 Answers

26
votes

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")
4
votes

Somewhat late, but after looking into this if you provide your own Client Bean the LoadBalancerFeignClient wont get built and used, and the Feign open tracing autoconfig will still work.

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