Package io.micronaut.retry.intercept
Class DefaultRetryInterceptor
java.lang.Object
io.micronaut.retry.intercept.DefaultRetryInterceptor
- All Implemented Interfaces:
Interceptor<Object,
,Object> MethodInterceptor<Object,
,Object> Ordered
@Singleton
public class DefaultRetryInterceptor
extends Object
implements MethodInterceptor<Object,Object>
A
MethodInterceptor
that retries an operation according to the specified
Retryable
annotation.- Since:
- 1.0
- Author:
- graemerocher
-
Field Summary
Fields inherited from interface io.micronaut.aop.Interceptor
ARGUMENT, CACHEABLE_LAZY_TARGET, HOTSWAP, LAZY, PROXY_TARGET
Fields inherited from interface io.micronaut.core.order.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
-
Constructor Summary
ConstructorsConstructorDescriptionDefaultRetryInterceptor
(ConversionService conversionService, ApplicationEventPublisher eventPublisher, ExecutorService executorService) Construct a default retry method interceptor with the event publisher. -
Method Summary
Modifier and TypeMethodDescriptionint
getOrder()
intercept
(MethodInvocationContext<Object, Object> context) Extended version of theMethodInterceptor.intercept(InvocationContext)
method that accepts aMethodInvocationContext
.protected void
sleep
(long delayMillis) Performs the sleep between retries, can be overridden to customize the sleep behavior.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface io.micronaut.aop.MethodInterceptor
intercept
-
Constructor Details
-
DefaultRetryInterceptor
public DefaultRetryInterceptor(ConversionService conversionService, ApplicationEventPublisher eventPublisher, @Named("scheduled") ExecutorService executorService) Construct a default retry method interceptor with the event publisher.- Parameters:
conversionService
- The conversion serviceeventPublisher
- The event publisher to publish retry eventsexecutorService
- The executor service to use for completable futures
-
-
Method Details
-
getOrder
public int getOrder() -
intercept
Description copied from interface:MethodInterceptor
Extended version of theMethodInterceptor.intercept(InvocationContext)
method that accepts aMethodInvocationContext
.- Specified by:
intercept
in interfaceMethodInterceptor<Object,
Object> - Parameters:
context
- The context- Returns:
- The result
-
sleep
Performs the sleep between retries, can be overridden to customize the sleep behavior. The default implementation just callsThread.sleep(long)
.- Throws:
InterruptedException
-