I am trying to use @FeignClient
for the first time in a simple REST client test application. I want to make use of Ribbon for the load balancing between two server instances, but not use Eureka. Following the documentation I have configured my application.yml
with the listOfServers
property and disabled Eureka. My client is named with the same name as the YAML prefix for the ribbon
properties.
application.yml
:
ds:
ribbon:
listOfServers: server1:18201,server2:18201
Client code:
@FeignClient("ds")
public interface DataServicesClient {
@RequestMapping(method = RequestMethod.GET, value = "/context-path/customers")
List<Customers> getCustomers();
}
When I invoke the application, I can see the listOfServers
being picked up by Ribbon:
2016-03-07 12:15:17.275 INFO 39948 --- [nio-8081-exec-1]
c.n.l.DynamicServerListLoadBalancer : DynamicServerListLoadBalancer for client ds
initialized: DynamicServerListLoadBalancer:{NFLoadBalancer:name=ds,current list of
Servers=[server1:18201, server2:18201]
However the client then makes a call using only the value of the @RequestMapping
annotation without the server prefix, and obviously fails.
2016-03-07 12:15:21.394 ERROR 39948 --- [nio-8081-exec-1] o.a.c.c.C.[.[.[/].
[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context
with path [] threw exception [Request processing failed; nested exception is
feign.RetryableException: Unexpected end of file from server executing GET
http://context-path/customers] with root cause
java.net.SocketException: Unexpected end of file from server
at sun.net.www.http.HttpClient.parseHTTPHeader(Unknown Source)
I was expecting it to inject each server in turn (http:{server instance}/context-path/customers
), so I obviously have missed something here.
Can anyone please point me in the right direction?
Thanks,
Rob.