本文共 4008 字,大约阅读时间需要 13 分钟。
新建一个service-turbine
pom
4.0.0 com.xiaobu springcloud-demo 0.0.1-SNAPSHOT service-turbine 0.0.1-SNAPSHOT service-turbine service-turbine project for Spring Boot 1.8 org.springframework.boot spring-boot-starter org.springframework.cloud spring-cloud-starter-netflix-eureka-client org.springframework.boot spring-boot-starter-actuator org.springframework.cloud spring-cloud-starter-netflix-hystrix org.springframework.cloud spring-cloud-starter-netflix-hystrix-dashboard org.springframework.cloud spring-cloud-starter-netflix-turbine org.springframework.cloud spring-cloud-dependencies ${spring-cloud.version} pom import org.springframework.boot spring-boot-maven-plugin
application.properties
server.port=8012spring.application.name=service-turbineeureka.client.serviceUrl.defaultZone=http://localhost:8001/eureka/management.endpoints.web.exposure.include=*management.endpoints.web.cors.allowed-origins=*management.endpoints.web.cors.allowed-methods=*turbine.app-config=hystrix-dashboard-service-hi,hystrix-dashboard-service-hi2turbine.aggregator.clusterConfig=defaultturbine.clusterNameExpression=new String("default")turbine.combine-host=trueturbine.instanceUrlSuffix.default=actuator/hystrix.stream
ServiceTurbineApplication.java
package com.xiaobu;import lombok.extern.slf4j.Slf4j;import org.springframework.beans.factory.annotation.Value;import org.springframework.boot.CommandLineRunner;import org.springframework.boot.SpringApplication;import org.springframework.boot.autoconfigure.SpringBootApplication;import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker;import org.springframework.cloud.client.discovery.EnableDiscoveryClient;import org.springframework.cloud.netflix.eureka.EnableEurekaClient;import org.springframework.cloud.netflix.hystrix.EnableHystrix;import org.springframework.cloud.netflix.hystrix.dashboard.EnableHystrixDashboard;import org.springframework.cloud.netflix.turbine.EnableTurbine;import org.springframework.web.bind.annotation.RestController;@SpringBootApplication@EnableEurekaClient@EnableDiscoveryClient@RestController@EnableHystrix@EnableHystrixDashboard@EnableCircuitBreaker@EnableTurbine@Slf4jpublic class ServiceTurbineApplication implements CommandLineRunner { public static void main(String[] args) { SpringApplication.run(ServiceTurbineApplication.class, args); } @Value("${server.port}") private String port; @Override public void run(String... args) throws Exception { log.info("service-turbine在端口:{},启动成功....",port); }}
依次启动eureka-server、hystrix-dashboard-service-hi(在不同的端口启动两个实例)、service-turbine
访问 http://localhost:8012/turbine.stream
请求 http://localhost:8010/hi?name=admin http://localhost:8011/hi?name=admin任意一个
访问 http://localhost:8010/hystrix 监控 http://localhost:8012/turbine.stream
鼠标悬浮数据上面可以看属性说明
参考:
转载地址:http://bkgai.baihongyu.com/