Database Reference
In-Depth Information
Auto retries and exponential back-offs
In the case of client errors, we can put some code around autoerror retries. Sometimes, it's
possible that your provisioned throughput is utilized to the maximum; in this case, it's good
to perform autoerror retries. The simplest way of performing this is using the client config-
uration provided by Amazon, as shown in the following code:
ClientConfiguration configuration = new
ClientConfiguration();
configuration.setMaxErrorRetry(3);
// Instantiate AWS Client with proper credentials and
client configuration
dynamoDBClient = new AmazonDynamoDBClient(
new ClasspathPropertiesFileCredentialsProvider(),
configuration);
Here, you can set the number as per your need. By default, Amazon has put some autoerror
retries policies that you can see from the Amazon SDK code, which is of 20,000 milli-
seconds, and the maximum error retries is three.
The Amazon SDK also allows you to create your own back-off policy, as shown in the fol-
lowing code:
ClientConfiguration configuration = new
ClientConfiguration();
RetryPolicy policy = new RetryPolicy(retryCondition,
backoffStrategy, maxErrorRetry,
honorMaxErrorRetryInClientConfig);
configuration.setRetryPolicy(retryPolicy);
// Instantiate AWS Client with proper credentials and client
configuration
dynamoDBClient = new AmazonDynamoDBClient(
new ClasspathPropertiesFileCredentialsProvider(),
configuration);
Some terms in the previous code are explained as follows:
Search WWH ::




Custom Search