【发布时间】:2016-12-01 10:36:11
【问题描述】:
我想从我的涡轮应用程序中读取在 consul 注册的服务。我为此配置了涡轮机:
Bootstrap.yml
server:
port: 8050
spring:
cloud:
consul:
discovery:
prefer-ip-address: true
host: *****hostName where consul reside****
port: 8500
turbine:
aggregator:
clusterConfig: dm-geo
appConfig: dm-geo
有依赖关系-
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-hystrix-dashboard</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-netflix-turbine</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-consul-discovery</artifactId>
</dependency>
在主应用程序类 -
@EnableTurbine
@EnableHystrixDashboard
@EnableDiscoveryClient
所有这些配置都是在涡轮应用上完成的。
现在在 consul 上注册的每个服务都有依赖关系 -
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-hystrix</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-consul-discovery</artifactId>
</dependency>
和
@EnableHystrix
@EnableDiscoveryClient
在带有HystrixCommand 的应用程序类上,我们使用适当的回退逻辑调用其他服务的方法。
application.properties:-
spring.application.name=dm-geo
现在我们的 python 脚本需要配置发现这些服务并在 consul 上注册。 当我尝试获取每个 hystrix.stream 时,我可以为此获取 hystrix 仪表板。
但从我的涡轮机应用程序中,错误记录为
"timestamp":"2016-07-27T17:33:14.406+05:30","message":"Could not initiate connection to host, giving up,"logger_name":"com netflix turbine monitor instance InstanceMonitor","thread_name":"InstanceMonitor"
有人可以在这方面提供帮助吗???
【问题讨论】:
-
spring.application.name 需要进入 bootstrap.properties,你试过了吗?
-
是的,今天我在做这个。现在已经解决了。至于我们的应用程序turbine.stream 是一个经过身份验证的URL,所以我必须跳过它,然后它可以完美地显示涡轮流和仪表板。作为 security.ignored = URL 路径。
标签: java spring-cloud consul hystrix turbine