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
ConstructorsConstructorDescriptionSpringRetryTemplateAdapter
(org.springframework.retry.support.RetryTemplate retryTemplate) -
Method Summary
Modifier and TypeMethodDescription<R> @Nullable R
execute
(org.springframework.core.retry.Retryable<? extends @Nullable R> retryable) void
setRecoveryCallback
(org.springframework.retry.RecoveryCallback<?> recoveryCallback) Set aRecoveryCallback
to be used in theRetryTemplate.execute(RetryCallback, RecoveryCallback)
delegating operation.void
setRetryPolicy
(org.springframework.core.retry.RetryPolicy retryPolicy) Methods inherited from class org.springframework.core.retry.RetryTemplate
setRetryListener
-
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 classorg.springframework.core.retry.RetryTemplate
-
setRecoveryCallback
public void setRecoveryCallback(org.springframework.retry.RecoveryCallback<?> recoveryCallback) Set aRecoveryCallback
to be used in theRetryTemplate.execute(RetryCallback, RecoveryCallback)
delegating operation. This is exactly aRecoveryCallback
used previously in the target service alongside with aRetryTemplate
.- Parameters:
recoveryCallback
- theRecoveryCallback
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 interfaceorg.springframework.core.retry.RetryOperations
- Overrides:
execute
in classorg.springframework.core.retry.RetryTemplate
- Throws:
org.springframework.core.retry.RetryException
-