Spring Integration

org.springframework.integration.handler.advice
Class RequestHandlerRetryAdvice

java.lang.Object
  extended by org.springframework.integration.context.IntegrationObjectSupport
      extended by org.springframework.integration.handler.advice.AbstractRequestHandlerAdvice
          extended by org.springframework.integration.handler.advice.RequestHandlerRetryAdvice
All Implemented Interfaces:
org.aopalliance.aop.Advice, org.aopalliance.intercept.Interceptor, org.aopalliance.intercept.MethodInterceptor, org.springframework.beans.factory.Aware, org.springframework.beans.factory.BeanFactoryAware, org.springframework.beans.factory.BeanNameAware, org.springframework.beans.factory.InitializingBean, 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
 
Field Summary
 
Fields inherited from class org.springframework.integration.handler.advice.AbstractRequestHandlerAdvice
logger
 
Constructor Summary
RequestHandlerRetryAdvice()
           
 
Method Summary
<T> void
close(org.springframework.retry.RetryContext context, org.springframework.retry.RetryCallback<T> callback, java.lang.Throwable throwable)
           
protected  java.lang.Object doInvoke(AbstractRequestHandlerAdvice.ExecutionCallback callback, java.lang.Object target, Message<?> message)
          Subclasses implement this method to apply behavior to the MessageHandler.

callback.execute() invokes the handler method and returns its result, or null.

<T> void
onError(org.springframework.retry.RetryContext context, org.springframework.retry.RetryCallback<T> callback, java.lang.Throwable throwable)
           
protected  void onInit()
          Subclasses may implement this for initialization logic.
<T> boolean
open(org.springframework.retry.RetryContext context, org.springframework.retry.RetryCallback<T> callback)
           
 void setRecoveryCallback(org.springframework.retry.RecoveryCallback<java.lang.Object> recoveryCallback)
           
 void setRetryStateGenerator(RetryStateGenerator retryStateGenerator)
           
 void setRetryTemplate(org.springframework.retry.support.RetryTemplate retryTemplate)
           
 
Methods inherited from class org.springframework.integration.handler.advice.AbstractRequestHandlerAdvice
invoke, unwrapExceptionIfNecessary, unwrapThrowableIfNecessary
 
Methods inherited from class org.springframework.integration.context.IntegrationObjectSupport
afterPropertiesSet, getBeanFactory, getComponentName, getComponentType, getConversionService, getTaskScheduler, setBeanFactory, setBeanName, setComponentName, setConversionService, setTaskScheduler, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

RequestHandlerRetryAdvice

public RequestHandlerRetryAdvice()
Method Detail

setRetryTemplate

public void setRetryTemplate(org.springframework.retry.support.RetryTemplate retryTemplate)

setRecoveryCallback

public void setRecoveryCallback(org.springframework.retry.RecoveryCallback<java.lang.Object> recoveryCallback)

setRetryStateGenerator

public void setRetryStateGenerator(RetryStateGenerator retryStateGenerator)

onInit

protected void onInit()
               throws java.lang.Exception
Description copied from class: IntegrationObjectSupport
Subclasses may implement this for initialization logic.

Overrides:
onInit in class IntegrationObjectSupport
Throws:
java.lang.Exception

doInvoke

protected java.lang.Object doInvoke(AbstractRequestHandlerAdvice.ExecutionCallback callback,
                                    java.lang.Object target,
                                    Message<?> message)
                             throws java.lang.Exception
Description copied from class: AbstractRequestHandlerAdvice
Subclasses implement this method to apply behavior to the MessageHandler.

callback.execute() invokes the handler method and returns its result, or null.

Specified by:
doInvoke in class AbstractRequestHandlerAdvice
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.
Throws:
java.lang.Exception

open

public <T> boolean open(org.springframework.retry.RetryContext context,
                        org.springframework.retry.RetryCallback<T> callback)
Specified by:
open in interface org.springframework.retry.RetryListener

close

public <T> void close(org.springframework.retry.RetryContext context,
                      org.springframework.retry.RetryCallback<T> callback,
                      java.lang.Throwable throwable)
Specified by:
close in interface org.springframework.retry.RetryListener

onError

public <T> void onError(org.springframework.retry.RetryContext context,
                        org.springframework.retry.RetryCallback<T> callback,
                        java.lang.Throwable throwable)
Specified by:
onError in interface org.springframework.retry.RetryListener

Spring Integration