Spring Cloud 2-Hystrix 断路容错保护(四)
Spring Cloud Hystrix
Hello World!
关闭服务在访问
访问: http://localhost:8091/hystrix/hi
error http://localhost:8091/hystrix/he
Hello World!
关闭服务再访问:
访问: http://localhost:8091/hystrix/he
error-feign
- 1.RestTemplate 容错
- pom.xml
- application.yml
- application.java
- HelloService.java
- Controller.java
- 2.FeignClient 容错
- pom.xml
- application.yml
- Application.java
- ServiceClient.java
- Fallback.java
容错保护就是当请求的服务报错或者超时时,可以优雅降级.介绍两种实现:
- RestTemplate 容错
- FeignClient 容错
Hello World!
关闭服务在访问
访问: http://localhost:8091/hystrix/hi
error http://localhost:8091/hystrix/he
Hello World!
关闭服务再访问:
访问: http://localhost:8091/hystrix/he
error-feign