一、服务熔断
@HystrixCommand注解
name="circuitBreaker.enabled",value="true"
name="circuitBreaker.requestVolumeThreshold",value="10" // 设置在一个滚动窗口中,打开断路器的最少请求数
name="circuitBreaker.sleepWindowInMilliseconds",value="10000" // 设置在回路被打开,拒绝请求到再次尝试请求并决定回路是否继续打开的时间
name="circuitBreaker.errorThresholdPercentage",value="60" // 错误率达到60%触发降级
参考:https://www.jianshu.com/p/397...
配置
hystrix:
command:
default: // 默认是所有方法
execution:
isolation:
thread:
timeoutInMilliseconds: 2000
getProductInfoList: // 为指定方法设置超时时间
execution:
isolation:
thread:
timeoutInMilliseconds: 3000
feign: // feign-hystrix
hystrix:
enabled: true
logging:
level:
org.springframework.cloud.netflix.feign: debug // 日志级别调整
依赖
<dependency>
<group>org.springframework.cloud</group>
<artifactId>spring-cloud-starter-hytrsix</artifactId>
</dependency>
<dependency>
<group>org.springframework.cloud</group>
<artifactId>spring-cloud-starter-hytrsix-dashboard-</artifactId>
</dependency> // 需要在启动类上加注解:@EnabledHystrixDashboard
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。