public abstract class RetryPolicy extends Object
ConnectionStringBuilder
which guides senders and receivers to automatically retry the failed operation before throwing the exception to the client application.
Users should not implement this class, instead should use one of the provided implementations through getDefault()
or getNoRetry()
.Modifier | Constructor and Description |
---|---|
protected |
RetryPolicy(String name)
Creates an instance of RetryPolicy with the given name.
|
Modifier and Type | Method and Description |
---|---|
static RetryPolicy |
getDefault()
Retry policy that provides exponentially increasing retry intervals with each successive failure.
|
Duration |
getNextRetryInterval(String clientId,
Exception lastException,
Duration remainingTime)
Gets the interval after which nextRetry should be attempted, based on the last exception encountered and the remaining time before the operation times out.
|
static RetryPolicy |
getNoRetry()
Gets a retry policy that doesn't retry any operations, effectively disabling retries.
|
protected int |
getRetryCount(String clientId) |
void |
incrementRetryCount(String clientId)
Increments the number of successive retry attempts made by a client.
|
static boolean |
isRetryableException(Exception exception)
Determines if an exception is retry-able or not.
|
protected abstract Duration |
onGetNextRetryInterval(String clientId,
Exception lastException,
Duration remainingTime,
int baseWaitTime)
Adjusts the interval after which nextRetry should be attempted, based on the last exception encountered, the remaining time before the operation times out and the minimum wait time before retry.
|
void |
resetRetryCount(String clientId)
Resets the number of retry attempts made by a client.
|
String |
toString() |
protected RetryPolicy(String name)
name
- name of the policypublic void incrementRetryCount(String clientId)
clientId
- id of the client retrying a failed operationpublic void resetRetryCount(String clientId)
clientId
- id of the client that just retried a failed operation and succeeded.public static boolean isRetryableException(Exception exception)
exception
- exception encountered by an operation, to be determined if it is retry-able.public static RetryPolicy getDefault()
public static RetryPolicy getNoRetry()
protected int getRetryCount(String clientId)
public Duration getNextRetryInterval(String clientId, Exception lastException, Duration remainingTime)
clientId
- id of the sender or receiver or client object that encountered the exception.lastException
- last exception encounteredremainingTime
- remainingTime to retry before the operation times outprotected abstract Duration onGetNextRetryInterval(String clientId, Exception lastException, Duration remainingTime, int baseWaitTime)
clientId
- id of the sender or receiver or client object that encountered the exception.lastException
- last exception encounteredremainingTime
- remainingTime to retry before the operation times outbaseWaitTime
- minimum wait time determined by the base retry policy. Overriding methods can return a different value.Copyright © 2019 Microsoft Corporation. All rights reserved.