Search code examples
azure-blob-storageazure-sdkazure-sdk-for-java

What is the difference between RetryOptions and RequestRetryOptions?


I am working with the Azure SDK for Java and specifically with blob storage and I am using the SpecializedBlobClientBuilder.

My question is around the various retry options:

SpecializedBlobClientBuilder retryOptions(RequestRetryOptions retryOptions)
SpecializedBlobClientBuilder retryOptions(RetryOptions retryOptions)

Initially I set RetryOptions on my client, but it did not seem to take effect in the case of a network timeout. However when I set RequestRetryOptions instead it does get applied and I am having trouble understanding why, what is the difference between these retry options and in which cases does RetryOptions actually get applied?


Solution

  • SpecializedBlobClientBuilder class provides options for configuring retries when interacting with Azure Blob Storage using Java.

    1. SpecializedBlobClientBuilder retryOptions(RequestRetryOptions retryOptions):

    As mentioned in the MSDOC, RequestRetryOptions class allows to configure options specifically related to retrying individual HTTP requests made by SDK client.

    enter image description here

    • It is used for scenarios like network timeouts, connection failures, and other issues encountered while sending a request.

    • If you set RequestRetryOptions on your client, it will affect the retry behavior of every request made through that particular client.

    1. SpecializedBlobClientBuilder retryOptions(RetryOptions retryOptions)

    As per MSDOC, this class is to configure retry policy for SDK client related to retrying higher-level operations and it handles retries at the operation level, which involve multiple HTTP requests

    enter image description here

    • If you set RetryOptions on your client, it will affect the retry behavior for higher-level operations.

    • To configure the retry policy for HTTP requests made by the client, use the RequestRetryOptions class.
    • To configure the retry policy for the client, use RetryOptions class.
    • Both RequestRetryOptions and RetryOptions are mutually exclusive. So, it is better to consider both classes while configuring storage options.

    References:

    Refer to the github repo for sample code to understand SpecializedBlobClientBuilder, RetryOptions and RequestRetryOptions.