简体   繁体   English

Spring-Circuit-Breaker-Resilience4j-嵌套故障转移

[英]Spring-Circuit-Breaker-Resilience4j-Nested Failover

I have multiple failover layers.我有多个故障转移层。 If my getData1() throws any exception, it must fall back to getData2() and if this method too throws exception then it must fall back to getData3().如果我的 getData1() 抛出任何异常,它必须回退到 getData2(),如果此方法也抛出异常,那么它必须回退到 getData3()。 I tried annotating the fallback method with circuit breaker as below but fail over is not happening when there is an exception in getData2().我尝试如下所示使用断路器注释回退方法,但是当 getData2() 中出现异常时,故障转移不会发生。

public List<MyResponse>  getData1(String id1, String id2){
          
    return service1.getDataById1(id1,id2);
}

@CircuitBreaker(name = "shared", fallbackMethod = "getData3")
public List<MyResponse>  getData2(String id1, String id2,Exception ex){
          
    return service2.getDataById2(id1,id2);
}

public List<MyResponse>  getData3(String id1, String id2){
    
    return service3.getDataById3(id1,id2);
}

I'm trying this nested circuit breaker implementation but could not find any solution.我正在尝试这个嵌套的断路器实现,但找不到任何解决方案。

The fallback method should accept one more parameter, ex.后备方法应该再接受一个参数,例如。 Throwable e, so that resilience4j will be able to invoked the fallback method and inject the error thrown in the first method. Throwable e,以便 resilience4j 能够调用回退方法并注入第一个方法中抛出的错误。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM