Get failure exception in @HystrixCommand fallback method

后端 未结 5 1324
-上瘾入骨i
-上瘾入骨i 2020-12-28 08:21

Is there a way to get the reason a HystrixCommand failed when using the @HystrixCommand annotation within a Spring Boot application? It looks like

5条回答
  •  一个人的身影
    2020-12-28 08:53

    I couldn't find a way to obtain the exception with the annotations, but i found HystrixPlugins , with that you can register a HystrixCommandExecutionHook and you can get the exact exception in that like this :

    HystrixPlugins.getInstance().registerCommandExecutionHook(new HystrixCommandExecutionHook() {
                @Override
                public  void onFallbackStart(final HystrixInvokable commandInstance) {
    
                }
            });
    

    The command instance is a GenericCommand.

提交回复
热议问题