Package com.azure.core.amqp
Class AmqpRetryPolicy
- java.lang.Object
-
- com.azure.core.amqp.AmqpRetryPolicy
-
- Direct Known Subclasses:
ExponentialAmqpRetryPolicy
,FixedAmqpRetryPolicy
public abstract class AmqpRetryPolicy extends Object
An abstract representation of a policy to govern retrying of messaging operations.
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
AmqpRetryPolicy(AmqpRetryOptions retryOptions)
Creates an instance with the given retry options.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract Duration
calculateRetryDelay(int retryCount, Duration baseDelay, Duration baseJitter, ThreadLocalRandom random)
Calculates the amount of time to delay before the next retry attempt based on theretryCount
,baseDelay
, andbaseJitter
.Duration
calculateRetryDelay(Throwable lastException, int retryCount)
Calculates the amount of time to delay before the next retry attempt.boolean
equals(Object obj)
int
getMaxRetries()
Gets the maximum number of retry attempts.AmqpRetryOptions
getRetryOptions()
Gets the set of options used to configure this retry policy.int
hashCode()
-
-
-
Constructor Detail
-
AmqpRetryPolicy
protected AmqpRetryPolicy(AmqpRetryOptions retryOptions)
Creates an instance with the given retry options. IfAmqpRetryOptions.getMaxDelay()
,AmqpRetryOptions.getDelay()
, orAmqpRetryOptions.getMaxRetries()
is equal toDuration.ZERO
or zero, requests failing with a retriable exception will not be retried.- Parameters:
retryOptions
- The options to set on this retry policy.- Throws:
NullPointerException
- ifretryOptions
isnull
.
-
-
Method Detail
-
getRetryOptions
public AmqpRetryOptions getRetryOptions()
Gets the set of options used to configure this retry policy.- Returns:
- The set of options used to configure this retry policy.
-
getMaxRetries
public int getMaxRetries()
Gets the maximum number of retry attempts.- Returns:
- The maximum number of retry attempts.
-
calculateRetryDelay
public Duration calculateRetryDelay(Throwable lastException, int retryCount)
Calculates the amount of time to delay before the next retry attempt.- Parameters:
lastException
- The last exception that was observed for the operation to be retried.retryCount
- The number of attempts that have been made, including the initial attempt before any retries.- Returns:
- The amount of time to delay before retrying the associated operation; if
null
, then the operation is no longer eligible to be retried.
-
calculateRetryDelay
protected abstract Duration calculateRetryDelay(int retryCount, Duration baseDelay, Duration baseJitter, ThreadLocalRandom random)
Calculates the amount of time to delay before the next retry attempt based on theretryCount
,baseDelay
, andbaseJitter
.- Parameters:
retryCount
- The number of attempts that have been made, including the initial attempt before any retries.baseDelay
- The base delay for a retry attempt.baseJitter
- The base jitter delay.random
- The random number generator. Can be utilised to calculate a random jitter value for the retry.- Returns:
- The amount of time to delay before retrying to associated operation; or
null
if the it cannot be retried.
-
-