Hystrix回退問題。 如果dbcall1由於某種故障而發生故障併發生短路,則dbcall2也將進入故障預警模式,直到電路打開。Hystrix回退處理2 dbcall
public class CommandHelloFailure extends HystrixCommand<String> {
private final String name;
public CommandHelloFailure(String name) {
super(HystrixCommandGroupKey.Factory.asKey("ExampleGroup"));
this.name = name;
}`enter code here`
String dbcall1()
{
new CommandHelloFailure().execute();
}
String dbcall2()
{
new CommandHelloFailure().execute();
}
@Override
protected String run() {
throw new RuntimeException("this command always fails");
}
@Override
protected String getFallback() {
return "Hello Failure " + name + "!";
}
}
但是我想獨立回退的方法(數據庫調用)。
您的代碼不能編譯。請編輯並修復 – rjdkolb
其僞代碼..我面臨的問題是1)如果dbcall1()由於實際故障而發生故障併發生短路,則對於withCircuitBreakerSleepWindowInMilliseconds時間,調用(dbcall1()和dbcall2 ())進入後備。 @rjdkolb – Nikita