Class 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
  • 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 a MessagingException.
      Parameters:
      retryTemplate - the retry template.
    • setRecoveryCallback

      public void setRecoveryCallback(org.springframework.retry.RecoveryCallback<Object> recoveryCallback)
    • setRetryStateGenerator

      public void setRetryStateGenerator(RetryStateGenerator retryStateGenerator)
    • onInit

      protected void onInit()
      Description copied from class: IntegrationObjectSupport
      Subclasses may implement this for initialization logic.
      Overrides:
      onInit in class IntegrationObjectSupport
    • doInvoke

      protected Object doInvoke(AbstractRequestHandlerAdvice.ExecutionCallback callback, Object target, Message<?> message)
      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.
    • 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 internal RetryListener implementation. The RequestHandlerRetryAdvice must not be used as a listener for external RetryTemplate instances.
      Set a ErrorMessageUtils.FAILED_MESSAGE_CONTEXT_KEY attribute into context.
      Specified by:
      open in interface org.springframework.retry.RetryListener
      Type Parameters:
      T - the type of object returned by the callback
      E - the type of exception it declares may be thrown
      Parameters:
      context - the current RetryContext.
      callback - the current RetryCallback.
      Returns:
      the open state.