[hystrix]openfeign+hystrix反复进降级方法问题
问题
# 开启服务降级
feign:
hystrix:
enabled: true
开启服务降级并设置降级fallback方法


调用list方法时可以正常获取服务提供端返回的数据并返回给浏览器,但是调用timeout时会无限进入对应的fallback方法,但是从日志可以看出服务提供端确实将数据正确返回
服务提供方的timeout方法里执行了睡眠1秒
服务端timeout方法

返回浏览器的数据

服务端返回数据

解决
需要在消费端配置文件中设置hystrix的超时等待时间
# hystrix设置
hystrix:
command:
default:
execution:
timeout:
enabled: true
isolation:
thread:
# 设置超时时间
timeoutInMilliseconds: 3000
Extra
Hytrix默认配置信息可以通过 HystrixCommandProperties 类查看

可以看到默认超时时间为1000ms,也就是1秒

浙公网安备 33010602011771号