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());
        }
    }
  • 相关阅读:
    初入angularJS [2]
    初入angularJS [1]
    ubuntu13.10 nginx
    Session对象详解[源于网络]
    二、Python变量
    一、计算机硬件及操作系统
    python进阶之装饰器之3如何利用装饰器强制函数上的类型检查
    python基础之闭包函数
    python进阶之装饰器之2.定义一个可接受参数的装饰器、如何定义一个属性可由用户修改的装饰器、定义一个能接受可选参数的装饰器
    python进阶之装饰器之1.如何定义一个基本的装饰器并使用,保留装饰器的元数据(原信息),逆向解得函数原信息
  • 原文地址:https://www.cnblogs.com/zhi-leaf/p/12143677.html
Copyright © 2011-2022 走看看