Feign的demo之解决超时问题

我们之前在第一次请求的时候会出现超时的问题,我们来参考github关于这个问题的解析。


地址:https://github.com/spring-cloud/spring-cloud-netflix/issues/768

默认的请求时间为1秒,超过这个时间便超时异常。那么顺着这个思路我们有如下解决方式:

1、把时间设长

这里设置5秒

[html]  view plain  copy
  1. hystrix:  
  2.   command:  
  3.       default:  
  4.         execution:  
  5.           isolation:  
  6.             thread:  
  7.               timeoutInMilliseconds: 5000  

2、把超时发生异常属性关闭

[html]  view plain  copy
  1. hystrix:  
  2.   command:  
  3.       default:  
  4.         execution:  
  5.           timeout:  
  6.             enabled: false  

3、禁用feign的hystrix

[html]  view plain  copy
  1. feign:  
  2.   hystrix:  
  3.     enabled: false  

这三种任意一种都能解决问题,已经实践过,只需要修改application.yml中添加这些配置即可。


关于Feign的几个demo的完整的项目原地址:

链接:http://pan.baidu.com/s/1dE3IiK5 密码:0oew 


猜你喜欢

转载自blog.csdn.net/qq_40784783/article/details/80277843
今日推荐