![](/img/trans.png)
[英]HystrixRunTimeException: <operation> timed-out and fallback failed
[英]Getting HystrixRuntimeException: Function timed-out and fallback failed
我正在使用 hystrix 1.5.3 并在我的本地机器上运行这段代码。
@HystrixCommand (groupKey = "BookService", commandKey = "BookService.BookDetail", commandProperties = {
@HystrixProperty (name = EXECUTION_ISOLATION_STRATEGY, value = "THREAD"),
@HystrixProperty (name = CIRCUIT_BREAKER_ENABLED, value = "true"),
@HystrixProperty (name = EXECUTION_TIMEOUT_ENABLED, value = "true"),
@HystrixProperty (name = EXECUTION_ISOLATION_THREAD_TIMEOUT_IN_MILLISECONDS, value = "1500")}, threadPoolProperties = {
@HystrixProperty (name = CORE_SIZE, value = "60"),
@HystrixProperty (name = MAX_QUEUE_SIZE, value = "60"),
@HystrixProperty (name = QUEUE_SIZE_REJECTION_THRESHOLD, value = "60"),
@HystrixProperty (name = KEEP_ALIVE_TIME_MINUTES, value = "1")
})
public String getBookDetail(String bookId)
{
log.info("Getting details");
...
}
在我们的服务器上它工作正常,但是我在本地机器上遇到了这个运行时异常。 我的本地服务器只是等待超时持续时间,最后抛出这个 HystrixRuntimeException。 另外,我没有定义任何后备,但我的情况不应该需要它。 期望它应该像在我们的生产服务器中一样正常工作。
com.netflix.hystrix.exception.HystrixRuntimeException: BookService.BookDetail timed-out and fallback failed.
at com.netflix.hystrix.AbstractCommand$21.call(AbstractCommand.java:793) ~[hystrix-core-1.5.3.jar:1.5.3]
at com.netflix.hystrix.AbstractCommand$21.call(AbstractCommand.java:768) ~[hystrix-core-1.5.3.jar:1.5.3]
at rx.internal.operators.OperatorOnErrorResumeNextViaFunction$1.onError(OperatorOnErrorResumeNextViaFunction.java:77) ~[rxjava-1.0.12.jar:1.0.12]
at rx.internal.operators.OperatorDoOnEach$1.onError(OperatorDoOnEach.java:70) ~[rxjava-1.0.12.jar:1.0.12]
at rx.internal.operators.OperatorDoOnEach$1.onError(OperatorDoOnEach.java:70) ~[rxjava-1.0.12.jar:1.0.12]
at com.netflix.hystrix.AbstractCommand$DeprecatedOnFallbackHookApplication$1.onError(AbstractCommand.java:1448) ~[hystrix-core-1.5.3.jar:1.5.3]
at com.netflix.hystrix.AbstractCommand$FallbackHookApplication$1.onError(AbstractCommand.java:1373) ~[hystrix-core-1.5.3.jar:1.5.3]
at rx.internal.operators.OperatorDoOnEach$1.onError(OperatorDoOnEach.java:70) ~[rxjava-1.0.12.jar:1.0.12]
我检查了函数没有被执行,因为日志没有被打印出来。 当我通过修改EXECUTION_ISOLATION_THREAD_TIMEOUT_IN_MILLISECONDS
来更改超时时,类似的行为发生在新的超时持续时间之后。 当我删除 @HystrixCommand 注释时,它工作正常,所以这意味着只有 Hystrix 存在一些问题。 hystrix 属性似乎是在注释中定义的属性,看起来不错。 这可能是因为 hystrix 没有正确配置吗? 任何帮助,将不胜感激。
您的函数未在 1500 毫秒内执行。
将 EXECUTION_TIMEOUT_ENABLED 更改为 false,hystrix 不会使您的方法超时。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.