FeignClient with absolute URL doesn't work using Spring Cloud Loadbalancer in Hoxton.RELEASE
With Spring Cloud Hoxton.RELEASE, FeignClient with ribbon disabled stopped respecting Absolute URLs.
FeignClient
@FeignClient(name = "feedback-client", url = "http://some.absolute.url")
interface FeedbackClient {
@RequestMapping(value = ["/feedback"], method = [RequestMethod.GET])
fun findAll(@RequestParam("page") page: Int): Page<Feedback>
}
application.yml
spring:
cloud:
loadbalancer:
ribbon:
enabled: false
Error:
s.c.o.l.FeignBlockingLoadBalancerClient : Load balancer does not contain an instance for the service <absolute http url>
Dependencies: - Spring Boot 2.2.1 - Spring Cloud Hoxton.RELEASE
Github Repo to reproduce the scenario:
https://github.com/cancerian0684/demo-openfeign
Stackoverflow thread:
https://stackoverflow.com/questions/59115379/feignclient-with-absolute-url-doesnt-work-using-spring-cloud-loadbalancer-in-ho
Comment From: echooymxq
Yes, there is a bug, when the url is not null, should get the FeignBlockingLoadBalancerClient delegate.
Comment From: nickcodefresh
Alas this doesn't work if you have spring-cloud-sleuth enabled.
When the following in executing in FeignCleitnFactoryBean
Client client = getOptional(context, Client.class);
if (client != null) {
if (client instanceof LoadBalancerFeignClient) {
// not load balancing because we have a url,
// but ribbon is on the classpath, so unwrap
client = ((LoadBalancerFeignClient) client).getDelegate();
}
if (client instanceof FeignBlockingLoadBalancerClient) {
// not load balancing because we have a url,
// but Spring Cloud LoadBalancer is on the classpath, so unwrap
client = ((FeignBlockingLoadBalancerClient) client).getDelegate();
}
builder.client(client);
}
client is a LacyTracingFeignClient