My current environment is a Spring Cloud setup using Eureka and I have multiple Feign clients in the application. What I want to do is to allow most of my Feign clients to resolve their services via the discovery server but prevent one or two from doing so in order to use my local instance that I am currently developing on. I'm running the service I'm developing and the client application locally.
I would like the client application to use discovery for all over service discovery and override one Feign Client to use only my local running service.
Is there a way to do this without disabling Eureka on the client? I have explored these two questions (one, two) and have not managed to get the listOfServers field to have any impact unless I disabled Eureka. If it matters in working on this I made the service I wish to connect to not register with eureka.
You can specify a URL for a specific FeignClient without disabling Eureka client with property <ribbonclientname>.ribbon.NIWSServerListClassName
property.
Assume that service id for directing routing is testA
. You can define the below property without disabling Eureka client.
testA:
ribbon:
NIWSServerListClassName: com.netflix.loadbalancer.ConfigurationBasedServerList
listOfServers: ${url for your test server}
If you specify com.netflix.loadbalancerConfigurationBasedServerList
as NIWSServerListClassName
, ribbon client inside your Feign client will use address that was given via listOfServers
property without disabling eureka.