ThrottlingRetryOptions Class
- java.
lang. Object - com.
azure. cosmos. ThrottlingRetryOptions
- com.
public final class ThrottlingRetryOptions
Encapsulates retry options in the Azure Cosmos DB database service.
Constructor Summary
Constructor | Description |
---|---|
ThrottlingRetryOptions() |
Creates a new instance of the Retry |
Method Summary
Modifier and Type | Method and Description |
---|---|
int |
getMaxRetryAttemptsOnThrottledRequests()
Gets the maximum number of retries in the case where the request fails because the service has applied rate limiting on the client. |
Duration |
getMaxRetryWaitTime()
Gets the maximum retry duration. |
Throttling |
setMaxRetryAttemptsOnThrottledRequests(int maxRetryAttemptsOnThrottledRequests)
Sets the maximum number of retries in the case where the request fails because the service has applied rate limiting on the client. |
Throttling |
setMaxRetryWaitTime(Duration maxRetryWaitTime)
Sets the maximum retry time in seconds. |
String | toString() |
Methods inherited from java.lang.Object
Constructor Details
ThrottlingRetryOptions
public ThrottlingRetryOptions()
Creates a new instance of the RetryOptions class and initializes all properties to default values.
Method Details
getMaxRetryAttemptsOnThrottledRequests
public int getMaxRetryAttemptsOnThrottledRequests()
Gets the maximum number of retries in the case where the request fails because the service has applied rate limiting on the client.
Returns:
getMaxRetryWaitTime
public Duration getMaxRetryWaitTime()
Gets the maximum retry duration.
Returns:
setMaxRetryAttemptsOnThrottledRequests
public ThrottlingRetryOptions setMaxRetryAttemptsOnThrottledRequests(int maxRetryAttemptsOnThrottledRequests)
Sets the maximum number of retries in the case where the request fails because the service has applied rate limiting on the client.
When a client is sending requests faster than the allowed rate, the service will return HttpStatusCode 429 (Too Many Request) to throttle the client. The current implementation in the SDK will then wait for the amount of time the service tells it to wait and retry after the time has elapsed.
The default value is 9. This means in the case where the request is throttled, the same request will be issued for a maximum of 10 times to the server before an error is returned to the application.
Parameters:
Returns:
setMaxRetryWaitTime
public ThrottlingRetryOptions setMaxRetryWaitTime(Duration maxRetryWaitTime)
Sets the maximum retry time in seconds.
When a request fails due to a throttle error, the service sends back a response that contains a value indicating the client should not retry before the time period has elapsed (Retry-After). The MaxRetryWaitTime flag allows the application to set a maximum wait time for all retry attempts. If the cumulative wait time exceeds the MaxRetryWaitTime, the SDK will stop retrying and return the error to the application.
The default value is 30 seconds.
Parameters:
Returns:
toString
public String toString()
Overrides:
ThrottlingRetryOptions.toString()Applies to
Azure SDK for Java
Feedback
https://aka.ms/ContentUserFeedback.
Coming soon: Throughout 2024 we will be phasing out GitHub Issues as the feedback mechanism for content and replacing it with a new feedback system. For more information see:Submit and view feedback for