Class DefaultRetryHandler
- java.lang.Object
-
- com.rabbitmq.client.impl.recovery.DefaultRetryHandler
-
- All Implemented Interfaces:
RetryHandler
public class DefaultRetryHandler extends Object implements RetryHandler
Composable topology recovery retry handler. This retry handler implementations let the user choose the condition to trigger retry and the retry operation for each type of recoverable entities. The number of attempts and the backoff policy (time to wait between retries) are also configurable.See also
TopologyRecoveryRetryHandlerBuilder
to easily create instances andTopologyRecoveryRetryLogic
for ready-to-use conditions and operations.- Since:
- 4.8.0
- See Also:
TopologyRecoveryRetryHandlerBuilder
,TopologyRecoveryRetryLogic
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
DefaultRetryHandler.RetryCondition<E extends RecordedEntity>
static class
DefaultRetryHandler.RetryOperation<T>
-
Constructor Summary
Constructors Constructor Description DefaultRetryHandler(DefaultRetryHandler.RetryCondition<? super RecordedQueue> queueRecoveryRetryCondition, DefaultRetryHandler.RetryCondition<? super RecordedExchange> exchangeRecoveryRetryCondition, DefaultRetryHandler.RetryCondition<? super RecordedBinding> bindingRecoveryRetryCondition, DefaultRetryHandler.RetryCondition<? super RecordedConsumer> consumerRecoveryRetryCondition, DefaultRetryHandler.RetryOperation<?> queueRecoveryRetryOperation, DefaultRetryHandler.RetryOperation<?> exchangeRecoveryRetryOperation, DefaultRetryHandler.RetryOperation<?> bindingRecoveryRetryOperation, DefaultRetryHandler.RetryOperation<?> consumerRecoveryRetryOperation, int retryAttempts, BackoffPolicy backoffPolicy)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected <T extends RecordedEntity>
RetryResultdoRetry(DefaultRetryHandler.RetryCondition<T> condition, DefaultRetryHandler.RetryOperation<?> operation, T entity, RetryContext context)
protected void
log(RecordedEntity entity, Exception exception, int attempts)
RetryResult
retryBindingRecovery(RetryContext context)
Retry a failed binding recovery operation.RetryResult
retryConsumerRecovery(RetryContext context)
Retry a failed consumer recovery operation.RetryResult
retryExchangeRecovery(RetryContext context)
Retry a failed exchange recovery operation.RetryResult
retryQueueRecovery(RetryContext context)
Retry a failed queue recovery operation.
-
-
-
Constructor Detail
-
DefaultRetryHandler
public DefaultRetryHandler(DefaultRetryHandler.RetryCondition<? super RecordedQueue> queueRecoveryRetryCondition, DefaultRetryHandler.RetryCondition<? super RecordedExchange> exchangeRecoveryRetryCondition, DefaultRetryHandler.RetryCondition<? super RecordedBinding> bindingRecoveryRetryCondition, DefaultRetryHandler.RetryCondition<? super RecordedConsumer> consumerRecoveryRetryCondition, DefaultRetryHandler.RetryOperation<?> queueRecoveryRetryOperation, DefaultRetryHandler.RetryOperation<?> exchangeRecoveryRetryOperation, DefaultRetryHandler.RetryOperation<?> bindingRecoveryRetryOperation, DefaultRetryHandler.RetryOperation<?> consumerRecoveryRetryOperation, int retryAttempts, BackoffPolicy backoffPolicy)
-
-
Method Detail
-
retryQueueRecovery
public RetryResult retryQueueRecovery(RetryContext context) throws Exception
Description copied from interface:RetryHandler
Retry a failed queue recovery operation.- Specified by:
retryQueueRecovery
in interfaceRetryHandler
- Parameters:
context
- the context of the retry- Returns:
- the result of the retry attempt
- Throws:
Exception
- if the retry fails
-
retryExchangeRecovery
public RetryResult retryExchangeRecovery(RetryContext context) throws Exception
Description copied from interface:RetryHandler
Retry a failed exchange recovery operation.- Specified by:
retryExchangeRecovery
in interfaceRetryHandler
- Parameters:
context
- the context of the retry- Returns:
- the result of the retry attempt
- Throws:
Exception
- if the retry fails
-
retryBindingRecovery
public RetryResult retryBindingRecovery(RetryContext context) throws Exception
Description copied from interface:RetryHandler
Retry a failed binding recovery operation.- Specified by:
retryBindingRecovery
in interfaceRetryHandler
- Parameters:
context
- the context of the retry- Returns:
- the result of the retry attempt
- Throws:
Exception
- if the retry fails
-
retryConsumerRecovery
public RetryResult retryConsumerRecovery(RetryContext context) throws Exception
Description copied from interface:RetryHandler
Retry a failed consumer recovery operation.- Specified by:
retryConsumerRecovery
in interfaceRetryHandler
- Parameters:
context
- the context of the retry- Returns:
- the result of the retry attempt
- Throws:
Exception
- if the retry fails
-
doRetry
protected <T extends RecordedEntity> RetryResult doRetry(DefaultRetryHandler.RetryCondition<T> condition, DefaultRetryHandler.RetryOperation<?> operation, T entity, RetryContext context) throws Exception
- Throws:
Exception
-
log
protected void log(RecordedEntity entity, Exception exception, int attempts)
-
-