gpt4 book ai didi

spring-boot - Spring Cloud Turbine - 无法处理多个客户端?

转载 作者:行者123 更新时间:2023-12-02 00:26:58 26 4
gpt4 key购买 nike

我在让 Turbine 在 Spring Cloud 中工作时遇到了一些麻烦。简而言之,我无法确定如何将其配置为一次聚合来自多个应用程序的电路。

我有 6 个独立的服务、一个 Eureka 服务器和一个以独立模式运行的涡轮机服务器。我可以从我的 Eureka 服务器上看到所有服务都已注册,包括涡轮机。我的涡轮机服务器已启动并正在运行,并且我可以毫无问题地查看其/hystrix 页面。但是当我尝试使用它来检查turbo.stream时,我只看到turbine.appConfig中列出的第一个服务器,其余的都被忽略。

这是我的 Turbine 服务器的 application.yml,或者至少是相关部分:

---
eureka:
client:
serviceUrl:
defaultZone: http://localhost:8010/eureka/
server:
port: 8030
info:
component: Turbine
turbine:
clusterNameExpression: new String(“default”)
appConfig: sentence,subject,verb,article,adjective,noun
management:
port: 8990

当我运行此程序并访问涡轮机实例上的 hystrix 仪表板并请求涡轮机.stream 时,输出中列出的唯一断路器适用于 appConfig 中列出的第一个服务,在本例中为“句子”服务。奇怪的是,如果我重新排列这些服务的顺序并将另一个服务放在第一位(如“名词”),我只会看到该服务的电路。仅显示列表中的第一个服务。

我承认对一些术语有点困惑,比如流、集群等,所以我可能会在这里遗漏一些基本概念,但我的理解是 Turbine 可以消化来自多个服务的流并将它们聚合在一个显示中。如有建议,我们将不胜感激。

最佳答案

我没有足够的声誉来发表评论,所以我必须在答案中写下这个:)

我遇到了完全相同的问题:

有两个服务“test-service”和“other-service”,每个服务都有自己的工作 hystrix-stream并且有一个 Turbine-Application,其配置如下:

    turbine:
clusterNameExpression: new String("default")
appConfig: test-service,other-service

我的所有服务都在我的本地计算机上运行。

结果是:我的 Hystrix-Dashboard 仅显示“test-service”的指标。

原因:

看起来,以所描述的方式配置的 Turbine 客户端在同一主机上运行时无法处理多个服务。

这里解释一下:

https://github.com/Netflix/Hystrix/issues/117#issuecomment-14262713

Turbine maintains state of all these instances in order to maintain persistent connections to them and it does rely on the "hostname" and if the host name is the same then it won't instantiate a new connection to that same server (on a different port).

所以要点是,您的所有服务都必须使用不同的主机名注册。下面描述了如何在本地计算机上执行此操作。

更新 2015-06-12/2016-01-23:本地测试的解决方法

更改您的主机文件:

    # ...
127.0.0.1 localhost
127.0.0.1 localdomain1
127.0.0.1 localdomain2
# ...
127.0.0.1 localdomainx

然后将每个客户端的主机名设置为不同的域条目,如下所示:
application.yml:

    eureka:
instance:
hostname: localdomainx

关于spring-boot - Spring Cloud Turbine - 无法处理多个客户端?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29934171/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com