返回目录
https://blog.csdn.net/BW_Bear/article/details/88746646
源码位置:
微服务注册管理:
https://github.com/zhaowei-zhang/CloudTest/tree/master/使用Hystrix实现容错/microservice-discovery-eureka
生产者:
https://github.com/zhaowei-zhang/CloudTest/tree/master/使用Hystrix实现容错/microservice-provider-user
Hystrix Dashboard项目:
https://github.com/zhaowei-zhang/CloudTest/tree/master/使用Hystrix实现容错/hystrix-dashboard
Turbine项目:
https://github.com/zhaowei-zhang/CloudTest/tree/master/使用Hystrix实现容错/hystrix-turbine
使用Hystrix Dashboard 可视化监控数据
1.新建可视化监控项目,加依赖
<!--hystrix 可视化监控 依赖-->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-hystrix-dashboard</artifactId>
<version>RELEASE</version>
</dependency>
2.启动类增加注解
3.修改配置文件
4.启动调接口,开监控页
打开新项目的可视化监控地址/hystrix
5.测试
当然要中文的话直接用谷歌网页翻译就好了,哈哈
使用Turbine 监控多个微服务
1.新建Turbine项目
2.加依赖
<!--hystrix 依赖-->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-turbine</artifactId>
<version>RELEASE</version>
</dependency>
<!--Eureka client 依赖-->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>
不要忘了cloud
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>Edgware.RELEASE</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
3.修改配置文件
server:
port: 9106
spring:
application:
name: hystrixturbine
eureka:
client:
service-url:
defaultZone: http://localhost:9100/eureka/
instance:
prefer-ip-address: true #表示将注解的IP注册到Eureka Server
turbine:
app-config: MICROSERVICE-CONSUMER-MOVIE-1,MICROSERVICE-CONSUMER-MOVIE-2
cluster-name-expression: "'default'"
4.启动生产者and消费者们
消费者们如下
MICROSERVICE-CONSUMER-MOVIE-1
MICROSERVICE-CONSUMER-MOVIE-2