Java Hystrix 命令失败并显示“超时且没有可用的回退”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/27375557/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Hystrix command fails with "timed-out and no fallback available"
提问by dkulkarni
I've noticed that some of the commands in my application fail with
我注意到我的应用程序中的一些命令失败了
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.access00(HystrixCommand.java:97)
out: ! at com.netflix.hystrix.HystrixCommand$TimeoutObservable.tick(HystrixCommand.java:1025)
out: ! at com.netflix.hystrix.HystrixCommand.performBlockingGetWithTimeout(HystrixCommand.java:621)
out: ! at com.netflix.hystrix.HystrixCommand.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
This is my Hystrix configuration override:
这是我的 Hystrix 配置覆盖:
hystrix.command.default.execution.isolation.thread.timeoutInMilliseconds=210000
hystrix.threadpool.default.coreSize=50
hystrix.threadpool.default.maxQueueSize=100
hystrix.threadpool.default.queueSizeRejectionThreshold=50
What kind of timeout is this? Is it a read/connection timeout to the external application? How do I go about debugging this?
这是什么样的超时?它是外部应用程序的读取/连接超时吗?我该如何调试?
回答by ahus1
Looking at the stacktrace this is an exception thrown by Hystrix after the 210 seconds you defined above.
查看堆栈跟踪,这是在您上面定义的 210 秒后由 Hystrix 抛出的异常。
As TimeoutException
is a checked exception that needs to be declared on each method that could throw this exception. You would see this declared in the run()
method of your code.
与TimeoutException
需要在可能引发此异常的每个方法上声明的已检查异常一样。您会在run()
代码的方法中看到这一点。
You can debug this like any other program, but be aware that the run()
method runs in a thread separate from the caller. After 210 seconds the caller will just continue despite your debugging session.
您可以像调试任何其他程序一样调试它,但要注意该run()
方法在与调用者分开的线程中运行。210 秒后,尽管您进行了调试会话,调用者仍将继续。
回答by xval
It might be you are in debug or your connection too slow, default thread execution timeout is only 1 second, so you could get this message easily if you put a break-point in your command let's say
可能是您正在调试或连接速度太慢,默认线程执行超时仅为 1 秒,因此如果您在命令中放置断点,您可以轻松收到此消息,假设
Although this is not your case but might help somebody else
虽然这不是你的情况,但可能会帮助别人
回答by Pushpak Jain
You should increase ur rest client httpclient readTimeout property
您应该增加您的休息客户端 httpclient readTimeout 属性
回答by psantamaria
This is a Hystrix Command Timeout, this timeout is enabled by default per each command, you define the value using the property:
这是一个 Hystrix 命令超时,默认情况下每个命令都启用此超时,您可以使用以下属性定义值:
execution.isolation.thread.timeoutInMilliseconds:This property sets the time in milliseconds after which the caller will observe a timeout and walk away from the command execution. Hystrix marks > the HystrixCommand as a TIMEOUT, and performs fallback logic.
execution.isolation.thread.timeoutInMilliseconds:此属性以毫秒为单位设置时间,在此之后调用者将观察到超时并离开命令执行。Hystrix 将 > HystrixCommand 标记为 TIMEOUT,并执行回退逻辑。
So you can increase your timeout value or disable the default time out (if apply in your case) for your command using the property:
因此,您可以使用以下属性为您的命令增加超时值或禁用默认超时(如果适用于您的情况):
@HystrixProperty(name = "hystrix.command.default.execution.timeout.enabled", value = "false")
@HystrixProperty(name = "hystrix.command.default.execution.timeout.enabled", value = "false")
You can find more information here: https://github.com/Netflix/Hystrix/wiki/Configuration#CommandExecution
您可以在此处找到更多信息:https: //github.com/Netflix/Hystrix/wiki/Configuration#CommandExecution