多个Eureka服务器配置不起作用

问题描述 投票:0回答:0

我正在使用 Spring Cloud Hoxton.SR10 和 Spring Boot 2.3.8.RELEASE

问题: 逗号分隔的 eureka 客户端引导配置无法正常工作。当客户端启动时,它仅检查 defaultZone 列表(peer1)中的第一个 eureka url,并且如果其关闭则不会尝试联系peer2。相同的配置在 Hoxton.SR4 中运行正常。

客户端引导配置:

spring:
  cloud:
    config:
      discovery:
        enabled: true
        serviceId: config-server
      failFast: true
      retry:
        max-interval: 5000
        max-attempts: 200
  application:
    name: eureka-test
eureka:
  client:
    serviceUrl: ##service-url behaves the same
      defaultZone: https://peer1:7777/eureka/,https://peer2:7777/eureka/

问题似乎出现在:

org.springframework.cloud.netflix.eureka.config.EurekaConfigServerBootstrapConfiguration
    private static String getEurekaUrl(EurekaClientConfigBean config, Environment env) {
        List<String> urls = EndpointUtils.getDiscoveryServiceUrls(config, "defaultZone", new EurekaConfigServerBootstrapConfiguration.HostnameBasedUrlRandomizer(env.getProperty("eureka.instance.hostname")));
        return (String)urls.get(0);
    }

此方法显式仅从 defaultZone 列表中获取第一个对等点并使用它创建客户端,而在 Hoxton.SR4 RetryableEurekaHttpClinet 中是通过 EurekaClientAutoConfiguration 创建的。

我在 spring-cloud tracker 中没有发现任何报告的此问题的错误,并且想知道我是否错过了某些内容,是否有依赖项或配置片段可以在可重试客户端上切换?也许有任何已知的解决方法? 降级或升级到 Spring Cloud 的工作版本还需要更改 Spring-Boot 版本,这在大项目中是一个痛苦。

附注 上一个 Hoxton 版本 SR12 中存在同样的问题,并且似乎也存在于 2020.0.1 中(尽管没有尝试这个)。

谢谢

spring-boot spring-cloud netflix-eureka
© www.soinside.com 2019 - 2024. All rights reserved.