The retry mechanism of the QuickBooks Online .NET SDK enables an app to handle transient errors such as dropped connections. Retries are supported for both synchronous and asynchronous calls.
The SDK uses the retry framework at the service client level. This enables you to set retry policies in the application settings file (Appsettings.json). You can modify the retry settings or override them without having to redeploy the application.
If a retry policy has been set, a method that encounters an exception is called repeatedly, maximizing the chances of a successful call. Retries are supported for the following types of exceptions:
If the method does not succeed during the retries, it throws a RetryExceededException
.
The following sections describe the different retry policies that can be set in the configuration file. The parameters of the <retry>
constructor determine the number and frequency of retries. You can define additional features in the config file. For additional information, see
Configuration.
1. Configure the Retry Policy
Linear retry policy
Use a linear retry policy to retry a specified number of times with a fixed specified interval between retry attempts. Include the following code in the configuration file and set the retry values:
1 2 3 4 5 6 7 8 | "Retry":{ "Mode": { "LinearRetry": { "Enable": "false", "RetryCount": "", "RetryInterval": "" }, } |
Use an exponential retry policy retries a specified number of times with a randomized exponential backoff scheme. Include the following code in the configuration file and set the retry values:
1 2 3 4 5 6 7 8 9 | "Retry":{ "Mode": { "IncrementatlRetry": { "Enable": "false", "RetryCount": "", "InitialInterval": "", "Increment":"" }, } |
Use an incremental retry policy retries a specified number of times with the specified incremental interval between retry attempts. Include the following code in the configuration file and set the retry values:
1 2 3 4 5 6 7 8 9 10 | "Retry":{ "Mode": { "ExponentialRetry": { "Enable": "false", "RetryCount": "", "MinBackoff": "", "MaxBackoff": "", "DeltaBackoff":"" }, } |
Note
Note
The SDK allows you to override configuration file settings. For information, see Configuration.
The following table lists the parameters of the preceding retry policy constructors:
Parameter | Description |
count |
An integer value that specifies the number of retries to attempt. Default is 3. |
interval |
A time span value that specifies the interval between retries. Default is 30. |
minBackoff |
A time span value that specifies the initial interval between retries. |
maxBackoff |
A time span value that specifies the maximum interval permitted between retries. |
deltaBackoff |
A time span value that specifies the delta to use when the block calculates the exponential intervals between retries. |
initialInterval |
A time span value that specifies the initial interval between retries. |
increment |
A time span value that specifies by how much the interval should increase between retries. |