Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable eureka lookup on specific @FeignClient

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!

like image 507
Pradeep Krishna Govindaraju Avatar asked Mar 12 '23 17:03

Pradeep Krishna Govindaraju


1 Answers

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.

like image 152
spencergibb Avatar answered Apr 01 '23 18:04

spencergibb