- hystrix熔断器的使用
- 添加依赖
- <dependency>
- <groupId>org.springframework.cloud</groupId>
- <artifactId>spring-cloud-starter-openfeign</artifactId>
- </dependency>
- <dependency>
- <groupId>org.springframework.cloud</groupId>
- <artifactId>spring-cloud-starter-netflix-hystrix</artifactId>
- </dependency>
- yml配置
- #设置Feign的配置
- feign:
- hystrix:
- # 开启Hystrix,否则@FeignClient中的fallbackFactory配置不起作用。
- enabled: true
- #-----------------Hystrix配置-----------------------
- hystrix:
- command:
- default:
- metrics:
- rollingStats:
- #设置滚动时间窗为5秒
- timeInMilliseconds: 5000
- execution:
- isolation:
- thread:
- # 设置命令执行的默认超时时间,单位毫秒
- timeoutInMilliseconds: 10000
- timeout:
- # 是否启用超时,如果不启用上面的值也不用配置。
- enabled: true
- circuitBreaker: