如何禁用特定@FeignClient 上的尤里卡查找 [英] How to disable eureka lookup on specific @FeignClient

查看:51
本文介绍了如何禁用特定@FeignClient 上的尤里卡查找的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个微服务,主要使用 @FeignClient 与其他微服务通信.这使用 Eureka 的服务发现机制非常有效.

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

现在我迫切需要使用 @FeignClient 连接到外部系统,并且仍然使用如下所示的配置执行负载平衡.

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 客户端:

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

application.yml:

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

从我浏览过的许多文档来看,建议禁用 eureka 以允许从可用的 listOfServers 中获取负载平衡.我确实跟进并使用以下配置来禁用它.

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.

有没有什么办法可以单独为外部系统的伪装客户端设置禁用eureka,但允许它为其他客户端正常运行?

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

提前致谢!

推荐答案

在 spring-cloud-netflix 1.2.0(Camden 发布系列的一部分)中,设置服务器列表实现的能力是 最近添加.

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

可能会在 8 月或 9 月的某个时间发布.

Probably released sometime in August or September.

这篇关于如何禁用特定@FeignClient 上的尤里卡查找的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆