为什么Spring Boot端口动态设置为0时Eureka无法检测到新的客户端实例?

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

我已验证 Spring 应用程序和 Eureka 服务器中的所有配置均已正确设置。但是,我遇到了一个问题,即已成功注册到 Eureka 的两个服务实例没有出现在 Eureka 仪表板上。以下是 server.port=0 时的 2 个实例

  • Instance 1 with dynamic port

  • Instance 1 with dynamic port

在尤里卡仪表板中:

  • Eureka Dash board

提供静态端口后

  • enter image description here

在尤里卡仪表板中:

in the Eureka dashboard - static port

发生这种情况有什么原因吗?其次,我无法请求这些客户,即:

String serviceBUrl = "http://INVENTORY-SERVICE/inventory";
List<InventoryResponse> inventoryResponseStocks = webClient
        .get()
        .uri(serviceBUrl, uriBuilder -> uriBuilder.queryParam("skuCode", skuCodes).build())
        .retrieve()
        .bodyToFlux(InventoryResponse.class)
        .collectList()
        .block();

错误:

io.netty.resolver.dns.DnsErrorCauseException: Query failed with NXDOMAIN
at io.netty.resolver.dns.DnsResolveContext.onResponse(..)(Unknown Source) ~[netty-resolver-dns-4.1.111.Final.jar:4.1.111.Final]
java spring spring-boot netflix-eureka
1个回答
0
投票

在 webClient 的配置文件中放置 @LoadBalanced,因为运行多个实例并使用 WebClient.Builder 在此处输入图像描述

然后将自动装配称为 私有最终 WebClient.Builder webClientBuilder;

然后调用 webclientbuilder 来获取 webclient 函数: webClientBuilder.build().get().uri()

这可能有助于解决问题

最新问题
© www.soinside.com 2019 - 2024. All rights reserved.