Class RequestHandlerRetryAdvice
java.lang.Object
org.springframework.integration.context.IntegrationObjectSupport
org.springframework.integration.handler.advice.AbstractRequestHandlerAdvice
org.springframework.integration.handler.advice.RequestHandlerRetryAdvice
- All Implemented Interfaces:
Advice
,Interceptor
,MethodInterceptor
,Aware
,BeanFactoryAware
,BeanNameAware
,InitializingBean
,ApplicationContextAware
,ExpressionCapable
,NamedComponent
,org.springframework.retry.RetryListener
public class RequestHandlerRetryAdvice
extends AbstractRequestHandlerAdvice
implements org.springframework.retry.RetryListener
Uses spring-retry to perform stateless or stateful retry.
Stateless retry means the retries are performed internally
by the
RetryTemplate
; stateful retry means the
exception is thrown but state is maintained to support
the retry policies. Stateful retry requires a
RetryStateGenerator
.- Since:
- 2.2
- Author:
- Gary Russell, Artem Bilan
-
Nested Class Summary
Nested classes/interfaces inherited from class org.springframework.integration.handler.advice.AbstractRequestHandlerAdvice
AbstractRequestHandlerAdvice.ExecutionCallback, AbstractRequestHandlerAdvice.ThrowableHolderException
-
Field Summary
Fields inherited from class org.springframework.integration.context.IntegrationObjectSupport
EXPRESSION_PARSER, logger
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected Object
doInvoke
(AbstractRequestHandlerAdvice.ExecutionCallback callback, Object target, Message<?> message) Subclasses implement this method to apply behavior to theMessageHandler
.protected void
onInit()
Subclasses may implement this for initialization logic.<T,
E extends Throwable>
booleanopen
(org.springframework.retry.RetryContext context, org.springframework.retry.RetryCallback<T, E> callback) Deprecated, for removal: This API element is subject to removal in a future version.void
setRecoveryCallback
(org.springframework.retry.RecoveryCallback<Object> recoveryCallback) void
setRetryStateGenerator
(RetryStateGenerator retryStateGenerator) void
setRetryTemplate
(org.springframework.retry.support.RetryTemplate retryTemplate) Set the retry template.Methods inherited from class org.springframework.integration.handler.advice.AbstractRequestHandlerAdvice
invoke, unwrapExceptionIfNecessary, unwrapThrowableIfNecessary
Methods inherited from class org.springframework.integration.context.IntegrationObjectSupport
afterPropertiesSet, extractTypeIfPossible, generateId, getApplicationContext, getApplicationContextId, getBeanDescription, getBeanFactory, getBeanName, getChannelResolver, getComponentName, getComponentType, getConversionService, getExpression, getIntegrationProperties, getMessageBuilderFactory, getTaskScheduler, isInitialized, setApplicationContext, setBeanFactory, setBeanName, setChannelResolver, setComponentName, setConversionService, setMessageBuilderFactory, setPrimaryExpression, setTaskScheduler, toString
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.springframework.retry.RetryListener
close, onError, onSuccess
-
Constructor Details
-
RequestHandlerRetryAdvice
public RequestHandlerRetryAdvice()
-
-
Method Details
-
setRetryTemplate
public void setRetryTemplate(org.springframework.retry.support.RetryTemplate retryTemplate) Set the retry template. Cause traversal should be enabled in the retry policy because user exceptions may be wrapped in aMessagingException
.- Parameters:
retryTemplate
- the retry template.
-
setRecoveryCallback
public void setRecoveryCallback(org.springframework.retry.RecoveryCallback<Object> recoveryCallback) -
setRetryStateGenerator
-
onInit
protected void onInit()Description copied from class:IntegrationObjectSupport
Subclasses may implement this for initialization logic.- Overrides:
onInit
in classIntegrationObjectSupport
-
doInvoke
protected Object doInvoke(AbstractRequestHandlerAdvice.ExecutionCallback callback, Object target, Message<?> message) Description copied from class:AbstractRequestHandlerAdvice
Subclasses implement this method to apply behavior to theMessageHandler
.callback.execute() invokes the handler method and returns its result, or null.
- Specified by:
doInvoke
in classAbstractRequestHandlerAdvice
- Parameters:
callback
- Subclasses invoke the execute() method on this interface to invoke the handler method.target
- The target handler.message
- The message that will be sent to the handler.- Returns:
- the result after invoking the
MessageHandler
.
-
open
@Deprecated(since="6.2", forRemoval=true) public <T,E extends Throwable> boolean open(org.springframework.retry.RetryContext context, org.springframework.retry.RetryCallback<T, E> callback) Deprecated, for removal: This API element is subject to removal in a future version.since 6.2 in favor of an internalRetryListener
implementation. TheRequestHandlerRetryAdvice
must not be used as a listener for externalRetryTemplate
instances.Set aErrorMessageUtils.FAILED_MESSAGE_CONTEXT_KEY
attribute into context.- Specified by:
open
in interfaceorg.springframework.retry.RetryListener
- Type Parameters:
T
- the type of object returned by the callbackE
- the type of exception it declares may be thrown- Parameters:
context
- the currentRetryContext
.callback
- the currentRetryCallback
.- Returns:
- the open state.
-
RetryListener
implementation.