学习Spring Cloud第十三课(解决第一次访问报超时的问题)

       在前几节课我们第一次访问http://localhost:8010/movie/1这个地址的时候经常会看到超时错误,这个错误其实是因为feign集成了hystrix,而hystrix默认的超时时间是1秒,如果我们的请求超过了1秒,那么就会报超时错误。

       针对这种情况,有三种方法可以解决:

       在microservice-simple-consumer-movie-feign-customizing的application.yml文件中配置如下三种方案中的一种(根据实际情况自行选择)

第一种:延长超时时间

       hystrix.command.default.execution.isolation.thread.timeoutInMilliseconds: 5000

第二种:禁用超时

       hystrix.command.default.execution.timeout.enabled: false

第三种:索性禁用feign的hystrix

       feign.hystrix.enabled: false

       然后我们再依次启动eureaka、两个不同端口的user工程、feign-customizing,然后访问http://localhost:8010/movie/1就会发现不会超时了。

猜你喜欢

转载自blog.csdn.net/u012453843/article/details/78725776