-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Labels
Description
断路器聚合监控Hystrix Turbine
- 基于笔记0x11的工程,创建一个名为service-lucy的服务,代码和eurekaclient一样,端口改为8663
- 创建service-turbine,加入Hystrix Turbine起步依赖
<dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-netflix-eureka-client</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-netflix-hystrix</artifactId> </dependency> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-netflix-hystrix-dashboard</artifactId> </dependency> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-netflix-turbine</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> </dependency>
- 在application加入注解
@EnableTurbine@SpringBootApplication @EnableEurekaClient @EnableDiscoveryClient @RestController @EnableHystrix @EnableHystrixDashboard @EnableCircuitBreaker @EnableTurbine public class ServiceTurbineApplication { public static void main(String[] args) { SpringApplication.run(ServiceTurbineApplication.class, args); } }
- 配置相关信息,turbine聚合eurekaclient与service-lucky的信息
server.port=8667 spring.application.name=service-lucky eureka.client.serviceUrl.defaultZone=http://localhost:8767/eureka/ management.endpoint.shutdown.enabled=true turbine.app-config=service-hi,service-lucy turbine.aggregator.cluster-config=default turbine.cluster-name-expression=new String("default") turbine.combine-host-port=true
- 依次启动以下工程
- eurekaclient 8662
- service-lucky 8663
- eurekaserver 8767
- service-turbine 8667
- 访问http://localhost:8667/turbine.stream ,可以看到请求数据信息
- 访问http://localhost:8662/hi?name=hugeterry ,http://localhost:8663/hi?name=hugeterry 看到返回信息
- 访问http://localhost:8663/hystrix ,配上http://localhost:8667/turbine.stream ,确认可看到2个服务的聚合数据
Reactions are currently unavailable