SpringCloud学习–基础–4.2–Hystrix–案例–服务降级和线程隔离
代码位置
https://gitee.com/DanShenGuiZu/learnDemo/tree/master/SpringCloud-learn/SpringCloud-learn/demo_service_invocation
1、环境准备
- 拷贝app_ribbon作为新项目app-hystrix
1.1、应用信息
应用名称 | 端口 | 方法 |
---|
app-hystrix | 8885 | hello |
2、代码
2.1、添加依赖
<!-- hystrix 熔断器-->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-hystrix</artifactId>
<version>2.2.10.RELEASE</version>
</dependency>
2.2、开启熔断
@EnableCircuitBreaker //开启熔断
2.3、方法层 服务降级和线程隔离
2.4、类层 服务降级和线程隔离