怎么说hystrix不会触发hystrix命令中的一些例外的回退

Laz*_*Guy 10 java netflix hystrix

我们通过直接扩展HystrixCommand类来使用hystrix功能.但是对于一些业务异常,正在触发hystrix的回退方法.

我不希望触发某些业务特定异常的hystrix回退.如何在没有基于注释的情况下实现它?

提前致谢..!

ser*_*sti 6

使用 ignoreExceptions 注释参数

@HystrixCommand(ignoreExceptions = { BaseException.class, MissingServletRequestParameterException.class, TypeMismatchException.class })
Run Code Online (Sandbox Code Playgroud)

https://github.com/Netflix/Hystrix/tree/master/hystrix-contrib/hystrix-javanica#error-propagation

我看到您正在扩展 HystrixCommand 而不是使用注释,但这没关系,只需在命令中设置该属性,它应该具有相同的效果。

不幸的是,Hystrix 命令是由 Builder 模式创建的,因此您必须进行一些黑客攻击。在 HystrixCommandBuilder 中使用的 DefaultProperties.java 中添加了 ignoreExceptions