春云|Feign Hytrix |首次呼叫超时 [英] Spring Cloud | Feign Hytrix | First Call Timeout

查看:33
本文介绍了春云|Feign Hytrix |首次呼叫超时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用 3 个假客户端的服务.每次启动应用程序时,我都会在第一次调用任何 feign 客户端时收到 TimeoutException.

I have a service that has uses 3 feign clients. Each time I start my application, I get a TimeoutException on the first call to any feign client.

在一切稳定之前,我必须至少触发每个假客户端一次.在网上环顾四周,问题在于 feign 或 hystrix 内部的某些内容是延迟加载的,解决方案是创建一个覆盖 spring 默认值的配置类.我已经用下面的代码试过了,但它仍然没有帮助.我仍然看到同样的问题.任何人都知道解决这个问题?通过 hystrix 回调两次调用 feignclient 是唯一的解决方案吗?

I have to trigger each feign client at least once before everything is stable. Looking around online, the problem is that something inside of feign or hystrix is lazy loaded and the solution was to make a configuration class that overrides the spring defaults. I've tried that wiith the below code and it is still not helping. I still see the same issue. Anyone know a fix for this? Is the only solution to call the feignclient twice via a hystrix callback?

 @FeignClient(value = "SERVICE-NAME", configuration =ServiceFeignConfiguration.class)     

 @Configuration
 public class ServiceFeignConfiguration {

     @Value("${service.feign.connectTimeout:60000}")
     private int connectTimeout;

     @Value("${service.feign.readTimeOut:60000}")
     private int readTimeout;

     @Bean
     public Request.Options options() {
         return new Request.Options(connectTimeout, readTimeout);
     }
 }

Spring Cloud - Brixton.SR4Spring Boot - 1.4.0.RELEASE

Spring Cloud - Brixton.SR4 Spring Boot - 1.4.0.RELEASE

这一切都在docker中运行Ubuntu - 12.04码头工人 - 1.12.1Docker-Compose - 1.8

This is all running in docker Ubuntu - 12.04 Docker - 1.12.1 Docker-Compose - 1.8

推荐答案

我发现解决方案是 Hystrix 的默认属性不好.他们有一个非常小的超时窗口,并且请求总是在第一次尝试时超时.我将这些属性添加到我的配置服务中的 application.yml 文件中,现在我所有的服务都可以毫无问题地使用 feign,而且我不必在第一次超时附近编码

I found the solution to be that the default properties of Hystrix are not good. They have a very small timeout window and the request will always time out on the first try. I added these properties to my application.yml file in my config service and now all of my services can use feign with no problems and i dont have to code around the first time timeout

hystrix:
 threadpool.default.coreSize: "20"
 threadpool.default.maxQueueSize: "500000"
 threadpool.default.keepAliveTimeMinutes: "2"
 threadpool.default.queueSizeRejectionThreshold: "500000"
 command:
   default:
     fallback.isolation.semaphore.maxConcurrentRequests: "20"
     execution:
       timeout:
         enabled: "false"
       isolation:
         strategy: "THREAD"
         thread:
           timeoutInMilliseconds: "30000"

这篇关于春云|Feign Hytrix |首次呼叫超时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆