Class SpringRetryTemplateAdapter

java.lang.Object
org.springframework.core.retry.RetryTemplate
org.springframework.amqp.rabbit.retry.SpringRetryTemplateAdapter
All Implemented Interfaces:
org.springframework.core.retry.RetryOperations

public class SpringRetryTemplateAdapter extends org.springframework.core.retry.RetryTemplate
The RetryTemplate adapter for the RetryTemplate instance. The goal of this class is to simplify a migration path for existing retry infrastructure.

The super RetryTemplate is configured with "no retry" policy since all the retrying logic is delegated to the provided RetryTemplate.

NOTE: only stateless operations are delegated with implementation at the moment.

Author:
Artem Bilan
  • Constructor Summary

    Constructors
    Constructor
    Description
    SpringRetryTemplateAdapter(org.springframework.retry.support.RetryTemplate retryTemplate)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    <R> @Nullable R
    execute(org.springframework.core.retry.Retryable<? extends @Nullable R> retryable)
     
    void
    setRecoveryCallback(org.springframework.retry.RecoveryCallback<?> recoveryCallback)
    Set a RecoveryCallback to be used in the RetryTemplate.execute(RetryCallback, RecoveryCallback) delegating operation.
    void
    setRetryPolicy(org.springframework.core.retry.RetryPolicy retryPolicy)
     

    Methods inherited from class org.springframework.core.retry.RetryTemplate

    setRetryListener

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • SpringRetryTemplateAdapter

      public SpringRetryTemplateAdapter(org.springframework.retry.support.RetryTemplate retryTemplate)
  • Method Details

    • setRetryPolicy

      public void setRetryPolicy(org.springframework.core.retry.RetryPolicy retryPolicy)
      Overrides:
      setRetryPolicy in class org.springframework.core.retry.RetryTemplate
    • setRecoveryCallback

      public void setRecoveryCallback(org.springframework.retry.RecoveryCallback<?> recoveryCallback)
      Set a RecoveryCallback to be used in the RetryTemplate.execute(RetryCallback, RecoveryCallback) delegating operation. This is exactly a RecoveryCallback used previously in the target service alongside with a RetryTemplate.
      Parameters:
      recoveryCallback - the RecoveryCallback to use.
    • execute

      public <R> @Nullable R execute(org.springframework.core.retry.Retryable<? extends @Nullable R> retryable) throws org.springframework.core.retry.RetryException
      Specified by:
      execute in interface org.springframework.core.retry.RetryOperations
      Overrides:
      execute in class org.springframework.core.retry.RetryTemplate
      Throws:
      org.springframework.core.retry.RetryException