When a method is annotated by @Retryable
, the interceptor does not use RetryListener
s beans. The listeners are easy to plug in RetryTemplate
but could also be considered by the interceptor
```java @SpringBootApplication @EnableResilientMethods public class EntryPoint {
@Bean
RetryListener retryListener(){
return new RetryListener() {
@Override
public void beforeRetry(RetryPolicy retryPolicy, org.springframework.core.retry.Retryable<?> retryable) {
System.out.println("...");
}
@Override
public void onRetrySuccess(RetryPolicy retryPolicy, org.springframework.core.retry.Retryable<?> retryable, @Nullable Object result) {
System.out.println("...");
}
};
}
public static void main(String[] args) {
var ctx = SpringApplication.run(EntryPoint.class, args);
ctx.getBean(A.class).foo();
}
}
@Component class A { private boolean b = true;
@Retryable(includes = RuntimeException.class)
public void foo(){
if(b) {
b = false;
throw new RuntimeException();
}
System.out.println("ok");
}
}
Comment From: bclozel
Duplicates https://github.com/spring-projects/spring-framework/issues/35382