1.描述
Feign
接口调用注册中心服务,一般默认超时时间为:1秒
,超过一秒钟会超时报错
熔断
超时时间,默认也是1秒
2. 更改默认超时时间(开启Feign熔断)
更改配置文件:application.yml
添加注解
配置代码:
feign:
hystrix:
enabled: true #开启Feign的熔断功能
client:
config:
default:
connectTimeout: 5000 #连接超时时间2秒
readTimeout: 5000 #读超时时间2秒
hystrix:
command:
default:
execution:
isolation:
thread:
timeoutInMilliseconds: 10000 #设置熔断时间10秒
依赖:
<!-- 熔断-->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-hystrix</artifactId>
</dependency>