zoukankan      html  css  js  c++  java
  • Hystrix报错java.util.concurrent.TimeoutException: null

    完整错误如下:

    java.util.concurrent.TimeoutException: null
        at com.netflix.hystrix.AbstractCommand.handleTimeoutViaFallback(AbstractCommand.java:997) ~[hystrix-core-1.5.18.jar:1.5.18]
        at com.netflix.hystrix.AbstractCommand.access$500(AbstractCommand.java:60) ~[hystrix-core-1.5.18.jar:1.5.18]
        at com.netflix.hystrix.AbstractCommand$12.call(AbstractCommand.java:609) ~[hystrix-core-1.5.18.jar:1.5.18]
        at com.netflix.hystrix.AbstractCommand$12.call(AbstractCommand.java:601) ~[hystrix-core-1.5.18.jar:1.5.18]
        at rx.internal.operators.OperatorOnErrorResumeNextViaFunction$4.onError(OperatorOnErrorResumeNextViaFunction.java:140) ~[rxjava-1.3.8.jar:1.3.8]
        at rx.internal.operators.OnSubscribeDoOnEach$DoOnEachSubscriber.onError(OnSubscribeDoOnEach.java:87) ~[rxjava-1.3.8.jar:1.3.8]
        at rx.internal.operators.OnSubscribeDoOnEach$DoOnEachSubscriber.onError(OnSubscribeDoOnEach.java:87) ~[rxjava-1.3.8.jar:1.3.8]
        at com.netflix.hystrix.AbstractCommand$HystrixObservableTimeoutOperator$1.run(AbstractCommand.java:1142) ~[hystrix-core-1.5.18.jar:1.5.18]
        at com.netflix.hystrix.strategy.concurrency.HystrixContextRunnable$1.call(HystrixContextRunnable.java:41) ~[hystrix-core-1.5.18.jar:1.5.18]
        at com.netflix.hystrix.strategy.concurrency.HystrixContextRunnable$1.call(HystrixContextRunnable.java:37) ~[hystrix-core-1.5.18.jar:1.5.18]
        at com.netflix.hystrix.strategy.concurrency.HystrixContextRunnable.run(HystrixContextRunnable.java:57) ~[hystrix-core-1.5.18.jar:1.5.18]
        at com.netflix.hystrix.AbstractCommand$HystrixObservableTimeoutOperator$2.tick(AbstractCommand.java:1159) ~[hystrix-core-1.5.18.jar:1.5.18]
        at com.netflix.hystrix.util.HystrixTimer$1.run(HystrixTimer.java:99) ~[hystrix-core-1.5.18.jar:1.5.18]
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) ~[?:1.8.0_221]
        at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308) ~[?:1.8.0_221]
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180) ~[?:1.8.0_221]
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294) ~[?:1.8.0_221]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) ~[?:1.8.0_221]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) ~[?:1.8.0_221]
        at java.lang.Thread.run(Thread.java:748) [?:1.8.0_221]

    问了度娘,有关闭断路功能的,有断路时间调长的,完全不在点上,我的目的是测试Hystrix断路器功能,都关闭了,我还咋验证。后来发现在这个报错之上还有一行错误:

    com.netflix.hystrix.contrib.javanica.command.GenericCommand.getFallback 80 - failed to processed fallback is the method: 'failHi'. 

    调试com.netflix.hystrix.contrib.javanica.command.GenericCommand.getFallback方法,发现是断路@HystrixCommand注解定义fallbackMethod方法反射调用failHi失败,再次调试报错的failHi方法,最终发现是failHi方法中出现了RuntimeException异常,错误的实例代码如下:

    @HystrixCommand(fallbackMethod = "failHi")
    @ResponseBody
    @GetMapping("/hi3")
    public String hi3() {
        return restTemplate.getForObject("http://127.0.0.1:" + port + "/res", String.class);
    }
    
    public String failHi() {
        try {
            return doThings();
        } catch (Exception e) {
            throw new RuntimeException("失败," + e.getMessage());
        }
    }
  • 相关阅读:
    MAC上最好用的免费全能音乐播放器VOX 2.6.5
    Linux发行版的排行
    Linux发行版的排行
    ImageButton的背景设为透明或者半透明以及按下效果
    ImageButton的背景设为透明或者半透明以及按下效果
    软件缘-网友个人精心打造的精品软件收集
    软件缘-网友个人精心打造的精品软件收集
    滚动条
    em
    配色
  • 原文地址:https://www.cnblogs.com/zhi-leaf/p/12143677.html
Copyright © 2011-2022 走看看