Hystrix命令失败,显示“超时且无可用后备”

我注意到我的应用程序中的一些命令失败了

Caused by: ! com.netflix.hystrix.exception.HystrixRuntimeException: GetAPICommand timed-out and no fallback available. out: ! at com.netflix.hystrix.HystrixCommand.getFallbackOrThrowException(HystrixCommand.java:1631) out: ! at com.netflix.hystrix.HystrixCommand.access$2000(HystrixCommand.java:97) out: ! at com.netflix.hystrix.HystrixCommand$TimeoutObservable$1$1.tick(HystrixCommand.java:1025) out: ! at com.netflix.hystrix.HystrixCommand$1.performBlockingGetWithTimeout(HystrixCommand.java:621) out: ! at com.netflix.hystrix.HystrixCommand$1.get(HystrixCommand.java:516) out: ! at com.netflix.hystrix.HystrixCommand.execute(HystrixCommand.java:425) out: Caused by: ! java.util.concurrent.TimeoutException: null out: !... 11 common frames omitted 

这是我的Hystrix配置覆盖:

 hystrix.command.default.execution.isolation.thread.timeoutInMilliseconds=210000 hystrix.threadpool.default.coreSize=50 hystrix.threadpool.default.maxQueueSize=100 hystrix.threadpool.default.queueSizeRejectionThreshold=50 

这是什么样的超时? 它是外部应用程序的读/连接超时吗? 我该如何调试呢?

这是Hystrix命令超时,默认情况下每个命令启用此超时,您可以使用属性定义值:

execution.isolation.thread.timeoutInMilliseconds:此属性设置调用者观察超时并离开命令执行的时间(以毫秒为单位)。 Hystrix将HystrixCommand标记为TIMEOUT,并执行回退逻辑。

因此,您可以使用属性增加超时值或禁用命令的默认超时(如果适用于您的情况):

@HystrixProperty(name = "hystrix.command.default.execution.timeout.enabled", value = "false")

您可以在此处找到更多信息: https : //github.com/Netflix/Hystrix/wiki/Configuration#CommandExecution

可能是你在调试或你的连接太慢,默认线程执行超时只有1秒,所以如果你在命令中设置一个断点,你可以很容易地得到这个消息让我们说

虽然这不是你的情况,但可能会帮助别人

查看堆栈跟踪,这是Hystrix在您上面定义的210秒之后抛出的exception。

由于TimeoutException是一个经过检查的exception,需要在每个可能抛出此exception的方法上声明。 您会在代码的run()方法中看到这个声明。

您可以像调试任何其他程序一样调试此方法,但请注意run()方法在与调用方不同的线程中运行。 210秒后,尽管您的调试会话,调用者仍将继续。

你应该增加你的rest客户端httpclient readTimeout属性