Class DefaultRetryHandler
- java.lang.Object
-
- com.rabbitmq.client.impl.recovery.DefaultRetryHandler
-
- All Implemented Interfaces:
RetryHandler
public class DefaultRetryHandler extends java.lang.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
TopologyRecoveryRetryHandlerBuilderto easily create instances andTopologyRecoveryRetryLogicfor ready-to-use conditions and operations.- Since:
- 5.4.0
- See Also:
TopologyRecoveryRetryHandlerBuilder,TopologyRecoveryRetryLogic
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceDefaultRetryHandler.RetryOperation<T>
-
Field Summary
Fields Modifier and Type Field Description protected BackoffPolicybackoffPolicyprotected java.util.function.BiPredicate<? super RecordedBinding,java.lang.Exception>bindingRecoveryRetryConditionprotected DefaultRetryHandler.RetryOperation<?>bindingRecoveryRetryOperationprotected java.util.function.BiPredicate<? super RecordedConsumer,java.lang.Exception>consumerRecoveryRetryConditionprotected DefaultRetryHandler.RetryOperation<?>consumerRecoveryRetryOperationprotected java.util.function.BiPredicate<? super RecordedExchange,java.lang.Exception>exchangeRecoveryRetryConditionprotected DefaultRetryHandler.RetryOperation<?>exchangeRecoveryRetryOperationprivate static org.slf4j.LoggerLOGGERprotected java.util.function.BiPredicate<? super RecordedQueue,java.lang.Exception>queueRecoveryRetryConditionprotected DefaultRetryHandler.RetryOperation<?>queueRecoveryRetryOperationprotected intretryAttempts
-
Constructor Summary
Constructors Constructor Description DefaultRetryHandler(java.util.function.BiPredicate<? super RecordedQueue,java.lang.Exception> queueRecoveryRetryCondition, java.util.function.BiPredicate<? super RecordedExchange,java.lang.Exception> exchangeRecoveryRetryCondition, java.util.function.BiPredicate<? super RecordedBinding,java.lang.Exception> bindingRecoveryRetryCondition, java.util.function.BiPredicate<? super RecordedConsumer,java.lang.Exception> 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 RetryResultdoRetry(java.util.function.BiPredicate<RecordedEntity,java.lang.Exception> condition, DefaultRetryHandler.RetryOperation<?> operation, RecordedEntity entity, RetryContext context)protected voidlog(RecordedEntity entity, java.lang.Exception exception, int attempts)RetryResultretryBindingRecovery(RetryContext context)Retry a failed binding recovery operation.RetryResultretryConsumerRecovery(RetryContext context)Retry a failed consumer recovery operation.RetryResultretryExchangeRecovery(RetryContext context)Retry a failed exchange recovery operation.RetryResultretryQueueRecovery(RetryContext context)Retry a failed queue recovery operation.
-
-
-
Field Detail
-
LOGGER
private static final org.slf4j.Logger LOGGER
-
queueRecoveryRetryCondition
protected final java.util.function.BiPredicate<? super RecordedQueue,java.lang.Exception> queueRecoveryRetryCondition
-
exchangeRecoveryRetryCondition
protected final java.util.function.BiPredicate<? super RecordedExchange,java.lang.Exception> exchangeRecoveryRetryCondition
-
bindingRecoveryRetryCondition
protected final java.util.function.BiPredicate<? super RecordedBinding,java.lang.Exception> bindingRecoveryRetryCondition
-
consumerRecoveryRetryCondition
protected final java.util.function.BiPredicate<? super RecordedConsumer,java.lang.Exception> consumerRecoveryRetryCondition
-
queueRecoveryRetryOperation
protected final DefaultRetryHandler.RetryOperation<?> queueRecoveryRetryOperation
-
exchangeRecoveryRetryOperation
protected final DefaultRetryHandler.RetryOperation<?> exchangeRecoveryRetryOperation
-
bindingRecoveryRetryOperation
protected final DefaultRetryHandler.RetryOperation<?> bindingRecoveryRetryOperation
-
consumerRecoveryRetryOperation
protected final DefaultRetryHandler.RetryOperation<?> consumerRecoveryRetryOperation
-
retryAttempts
protected final int retryAttempts
-
backoffPolicy
protected final BackoffPolicy backoffPolicy
-
-
Constructor Detail
-
DefaultRetryHandler
public DefaultRetryHandler(java.util.function.BiPredicate<? super RecordedQueue,java.lang.Exception> queueRecoveryRetryCondition, java.util.function.BiPredicate<? super RecordedExchange,java.lang.Exception> exchangeRecoveryRetryCondition, java.util.function.BiPredicate<? super RecordedBinding,java.lang.Exception> bindingRecoveryRetryCondition, java.util.function.BiPredicate<? super RecordedConsumer,java.lang.Exception> 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 java.lang.Exception
Description copied from interface:RetryHandlerRetry a failed queue recovery operation.- Specified by:
retryQueueRecoveryin interfaceRetryHandler- Parameters:
context- the context of the retry- Returns:
- the result of the retry attempt
- Throws:
java.lang.Exception- if the retry fails
-
retryExchangeRecovery
public RetryResult retryExchangeRecovery(RetryContext context) throws java.lang.Exception
Description copied from interface:RetryHandlerRetry a failed exchange recovery operation.- Specified by:
retryExchangeRecoveryin interfaceRetryHandler- Parameters:
context- the context of the retry- Returns:
- the result of the retry attempt
- Throws:
java.lang.Exception- if the retry fails
-
retryBindingRecovery
public RetryResult retryBindingRecovery(RetryContext context) throws java.lang.Exception
Description copied from interface:RetryHandlerRetry a failed binding recovery operation.- Specified by:
retryBindingRecoveryin interfaceRetryHandler- Parameters:
context- the context of the retry- Returns:
- the result of the retry attempt
- Throws:
java.lang.Exception- if the retry fails
-
retryConsumerRecovery
public RetryResult retryConsumerRecovery(RetryContext context) throws java.lang.Exception
Description copied from interface:RetryHandlerRetry a failed consumer recovery operation.- Specified by:
retryConsumerRecoveryin interfaceRetryHandler- Parameters:
context- the context of the retry- Returns:
- the result of the retry attempt
- Throws:
java.lang.Exception- if the retry fails
-
doRetry
protected RetryResult doRetry(java.util.function.BiPredicate<RecordedEntity,java.lang.Exception> condition, DefaultRetryHandler.RetryOperation<?> operation, RecordedEntity entity, RetryContext context) throws java.lang.Exception
- Throws:
java.lang.Exception
-
log
protected void log(RecordedEntity entity, java.lang.Exception exception, int attempts)
-
-