Forum Discussion
nitinrahim
May 29, 2024Brass Contributor
Cosmos Db JAVA SDK Retry Policy
Hi Azure Cosmos Db Team, We haven't explicitly set retry policy in the event of throttling. Uses the default throttling retry policy. Below as seen from diagnostics. throttlingRetryOptions=R...
mannu2050
Microsoft
Jun 03, 2024setMaxRetryWaitTimeInSeconds(int maxRetryWaitTimeInSeconds) is the method which helps in setting the maximum retry time in seconds. After setting this up, you can validate it with getMaxRetryWaitTimeInSeconds(), if the object has got the correct value.
This method encapsulates the header x-ms-retry-after-ms whose core job to set the gap. It seems to me there is some problem inside the client code.
Just an example:
To use retryOptions you can use something like this:
ThrottlingRetryOptions retryOptions = new ThrottlingRetryOptions().setMaxRetryAttemptsOnThrottledRequests(1);
client1 = new CosmosClientBuilder()
.endpoint(AccountSettings.HOST)
.key(AccountSettings.MASTER_KEY)
.consistencyLevel(ConsistencyLevel.SESSION)
.contentResponseOnWriteEnabled(true)
.directMode()
.throttlingRetryOptions(retryOptions)
.buildAsyncClient();
I have copied this snippet from this sample https://github.com/Azure-Samples/azure-cosmos-java-sql-api-samples/blob/3a7314e6062c8edf9335f727aee1058cdcf24519/src/main/java/com/azure/cosmos/examples/throughputcontrol/async/ThroughputControlQuickstartAsync.java#L51
This method encapsulates the header x-ms-retry-after-ms whose core job to set the gap. It seems to me there is some problem inside the client code.
Just an example:
To use retryOptions you can use something like this:
ThrottlingRetryOptions retryOptions = new ThrottlingRetryOptions().setMaxRetryAttemptsOnThrottledRequests(1);
client1 = new CosmosClientBuilder()
.endpoint(AccountSettings.HOST)
.key(AccountSettings.MASTER_KEY)
.consistencyLevel(ConsistencyLevel.SESSION)
.contentResponseOnWriteEnabled(true)
.directMode()
.throttlingRetryOptions(retryOptions)
.buildAsyncClient();
I have copied this snippet from this sample https://github.com/Azure-Samples/azure-cosmos-java-sql-api-samples/blob/3a7314e6062c8edf9335f727aee1058cdcf24519/src/main/java/com/azure/cosmos/examples/throughputcontrol/async/ThroughputControlQuickstartAsync.java#L51