How to disable eureka lookup on specific @FeignClient

倾然丶 夕夏残阳落幕 提交于 2019-12-10 09:32:47

问题


I have a microservice that uses @FeignClient predominantly to talk to other micro-services. This works beautifuly using Eureka's service discovery mechanism.

Now I have a pressing need to use a @FeignClient to connect to an external system and still perform load balancing using configurations as shown below.

Feign client:

@FeignClient("externalServers")
public interface ExternalServersClient {
    @RequestMapping(method = RequestMethod.GET, value = "/someExternalUrl")
    ResponseEntity<Object> callExternalServer();
}

application.yml:

externalServers:
  ribbon:
    listOfServers: server1:18201,server2:18201

From many documentations that I have gone through, it is adviced to disable eureka to allow loadbalancing to be picked up from available listOfServers. I did follow that up and used following configuration to disable it.

application.yml:

ribbon:
  eureka:
    enabled: false

This allowed me to perform loadbalancing for feign client targeting external systems but all other feign clients that need to use service discovery broke.

Is there any way to disable eureka for feign client setup for external system alone but allow it to function normally for other clients?

Thanks in advance!


回答1:


In spring-cloud-netflix 1.2.0 (part of the Camden release train), the ability to set the server list implementation was recently added.

You'll be able to do the following:

externalServers:
  ribbon:
    NIWSServerListClassName: com.netflix.loadbalancer.ConfigurationBasedServerList
    listOfServers: server1:18201,server2:18201

Probably released sometime in August or September.



来源:https://stackoverflow.com/questions/38360182/how-to-disable-eureka-lookup-on-specific-feignclient

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!