我正在将弹性 4j 与 SpringBoot 一起使用。我看到resilience4j 注释只有在它们被放置在抛出异常的类中时才起作用。如果该类由另一个类扩展并且父类具有注释,则重试不起作用。
Resilience4j 配置
resilience4j.retry:
instances:
service:
maxRetryAttempts: 5
waitDuration: 1000
retryException:
- com.common.exception.RetriableException
家长班
@Retry(name = "service")
@Component
public class httpClient extends client{
// This method is invoked from outside
public HttpResponse<T> getResponse(
String url, Class<T> responseType) {
return super.getResponse(url, requestEntity, responseType);
}
}
儿童班
@Retry(name = "service") // Without this line, the retries don't work, even though it is present in the parent class
@Component
public class client{
public HttpResponse<T> getResponse(
String url, Class<T> responseType) {
//Impl which throws RetriableException
}
}
这是预期的行为吗?如果我遗漏了什么,你能告诉我吗