Retries

The retry mechanism of the QuickBooks Online Java SDK enables an app to handle transient errors such as dropped connections that may occur in requests sent to Data Services. Retries are supported for both synchronous and asynchronous calls.

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:

Customizations to the retry policy are made in the configuration file, intuit-config.xml. Create this file in your app project if it doesn’t already exist.

Configure the retry policy

The following sections describe the different retry policies that can be set in the configuration file. For information about other configuration customizations that can be made, see Configuration. Default settings are listed here.

Fixed retry policy

Retries 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
9
<intuit-config>
   <retry>
      <mode>fixed</mode>
      <fixed>
         <count>3</count>
         <interval>30</interval>
      </fixed>
   </retry>
</intuit-config>
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
<intuit-config>
   <retry>
      <mode>incremental</mode>
      <incremental>
         <count>3</count>
         <interval>30</interval>
         <increment>5</increment>
      </incremental>
   </retry>
</intuit-config>
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
10
11
<intuit-config>
   <retry>
      <mode>exponential</mode>
      <exponential>
         <count>3</count>
         <minBackoff>5</minBackoff>
         <maxBackoff>100</maxBackoff>
         <deltaBackoff>10</deltaBackoff>
      </exponential>
   </retry>
</intuit-config>

Note

Note

The SDK allows you to override configuration settings via the Config.setProperty method. For information, see Configuration.

Summary of retry policy parameters

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.