Class RetryAspect
java.lang.Object
io.github.resilience4j.retry.configure.RetryAspect
- All Implemented Interfaces:
java.lang.AutoCloseable,org.springframework.core.Ordered
public class RetryAspect
extends java.lang.Object
implements org.springframework.core.Ordered, java.lang.AutoCloseable
This Spring AOP aspect intercepts all methods which are annotated with a
Retry
annotation. The aspect will handle methods that return a RxJava2 reactive type, Spring Reactor
reactive type, CompletionStage type, or value type.
The RetryRegistry is used to retrieve an instance of a Retry for a specific name.
Given a method like this:
@Retry(name = "myService")
public String fancyName(String name) {
return "Sir Captain " + name;
}
each time the #fancyName(String) method is invoked, the method's execution will pass
through a a Retry according to the given config.
The fallbackMethod parameter signature must match either:
1) The method parameter signature on the annotated method or 2) The method parameter signature with a matching exception type as the last parameter on the annotated method
-
Field Summary
-
Constructor Summary
Constructors Constructor Description RetryAspect(RetryConfigurationProperties retryConfigurationProperties, io.github.resilience4j.retry.RetryRegistry retryRegistry, java.util.List<RetryAspectExt> retryAspectExtList, FallbackDecorators fallbackDecorators, SpelResolver spelResolver, io.github.resilience4j.core.ContextAwareScheduledThreadPoolExecutor contextAwareScheduledThreadPoolExecutor) -
Method Summary
Modifier and Type Method Description voidclose()intgetOrder()voidmatchAnnotatedClassOrMethod(io.github.resilience4j.retry.annotation.Retry retry)java.lang.ObjectretryAroundAdvice(org.aspectj.lang.ProceedingJoinPoint proceedingJoinPoint, io.github.resilience4j.retry.annotation.Retry retryAnnotation)
-
Constructor Details
-
RetryAspect
public RetryAspect(RetryConfigurationProperties retryConfigurationProperties, io.github.resilience4j.retry.RetryRegistry retryRegistry, @Autowired(required=false) java.util.List<RetryAspectExt> retryAspectExtList, FallbackDecorators fallbackDecorators, SpelResolver spelResolver, @Nullable io.github.resilience4j.core.ContextAwareScheduledThreadPoolExecutor contextAwareScheduledThreadPoolExecutor)- Parameters:
retryConfigurationProperties- spring retry config propertiesretryRegistry- retry definition registryretryAspectExtList- a list of retry aspect extensionsfallbackDecorators- the fallback decoratorsspelResolver- spel expression parser
-
-
Method Details
-
matchAnnotatedClassOrMethod
public void matchAnnotatedClassOrMethod(io.github.resilience4j.retry.annotation.Retry retry) -
retryAroundAdvice
public java.lang.Object retryAroundAdvice(org.aspectj.lang.ProceedingJoinPoint proceedingJoinPoint, @Nullable io.github.resilience4j.retry.annotation.Retry retryAnnotation) throws java.lang.Throwable- Throws:
java.lang.Throwable
-
getOrder
public int getOrder()- Specified by:
getOrderin interfaceorg.springframework.core.Ordered
-
close
public void close() throws java.lang.Exception- Specified by:
closein interfacejava.lang.AutoCloseable- Throws:
java.lang.Exception
-