[英]Resilience4j How to route to fallback method then return back to original method after specific amount of time
我正在使用 resilience4j 和 spring 启动,
我需要完成以下场景,
我尝试如下重试但不适合问题,
@Retry(name = "retryService", fallbackMethod = "fallback")
public String originalMethod(String data) throws InterruptedException {
//..... call external service
}
public String fallback(String data, Throwable t) {
logger.error("Inside retryfallback, cause – {}", t.toString());
return "Inside retryfallback method. Some error occurred ";
}
添加的属性
resilience4j.retry:
instances:
retryService:
maxRetryAttempts: 5
waitDuration: 50000
我认为您可以在达到故障限制以实现所需行为的某个时候使用断路器。
通过添加 @CircuitBreaker(...) 注释并为该实例指定 failureRateThreshold、waitDurationInOpenState 和其他所需的配置属性。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.