# ribbon超时时间
ribbon:
ConnectTimeout: 3000
ReadTimeout: 3000
# 开启hystrix熔断
feign:
hystrix:
enabled: true
# hystrix熔断
hystrix:
command:
default:
execution:
isolation:
thread:
# 一般情况下 hystrix熔断时间 > ribbon超时时间
timeoutInMilliseconds: 10000
假设被调用接口时间响应时间是7s,此时没有达到hystrix熔断时间10s,但超过ribbon超时时间6s,此时还会返回被调用接口的响应结果吗,还是给出hystrix的熔断信息 ?
不会返回调用接口的响应结果,会返回feign请求超时:feign.RetryableException: Read timed out executing POST http://******
而熔断超时报错是:com.netflix.hystrix.exception.HystrixRuntimeException: FeignDemo#demo() timed-out and no fallback available.
@FeignClient(name="URLSERVICE", url = "http://localhost:90/",
fallbackFactory = MerchantApiFallbackFactory.class)
public interface MerchantApi {
@PostMapping("/merchant/user/list")
TableDataInfo list(MerchantUser user);
}
若调用方式为 url调用,不会走ribbon,只会走hystrix断路器,此处正常返回被调用接口结果
@FeignClient(name="MERCHANT",fallbackFactory = MerchantApiFallbackFactory.class)
public interface MerchantApi {
@PostMapping("/merchant/user/list")
TableDataInfo list(MerchantUser user);
}
若调用方式为 微服务调用,会走ribbon,此处返回ribbon超时 feign.RetryableException: Read timed out