接着上一篇写Turbine组件。
从系统的整体运行状况来看,查看单个实例的Hystrix数据不是很有用。
Turbine是一个应用程序,它将所有相关的/hystrix.stream
端点聚合到一个组合的/turbine.stream
中,
以便在Hystrix dashboard中使用。
一、创建turbine-client 服务
二、修改配置文件
spring.application.name=turbine-client
# 应用服务 WEB 访问端口
server.port=8500
#服务中心地址
eureka.client.serviceUrl.defaultZone=http://localhost:8761/eureka/
#打开端点
management.endpoints.web.exposure.include=hystrix.stream,health,info
#配置eureka中需要监控的服务
turbine.app-config=RIBBON-CLIENT,FEIGN-CLIENT
#指定集群的名称为default
turbine.cluster-name-expression="default"
三、在启动类上添加注解
@EnableHystrix
@EnableHystrixDashboard
@EnableTurbine
package com.example.turbineclient;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.hystrix.EnableHystrix;
import org.springframework.cloud.netflix.hystrix.dashboard.EnableHystrixDashboard;
import org.springframework.cloud.netflix.turbine.EnableTurbine;
@SpringBootApplication
@EnableHystrix
@EnableHystrixDashboard
@EnableTurbine
public class TurbineClientApplication {
public static void main(String[] args) {
SpringApplication.run(TurbineClientApplication.class, args);
}
}
四、依次启动eureka-server、eureka-client、ribbon-client、feign-client、turbine-client服务
五、访问hystrix.stream,并测试turbine