Performing auto-retries on DynamoDB errors
As mentioned in the previous recipe, we can perform auto-retries on DynamoDB requests if we get errors. In this recipe, we are going to see how to perform auto-retries.
Getting ready
To get started with this recipe, you should have your workstation ready with the Eclipse IDE.
How to do it…
Auto-retries are required if we get any errors during the first request. We can use the Amazon client configurations to set our retry strategy. By default, the DynamoDB client auto-retries a request if any error is generated three times. If we think that this is not efficient for us, then we can define this on our own, as follows:
First of all, we need to create a custom implementation of
RetryCondition
. It contains a method calledshouldRetry
, which we need to implement as per our needs. Here is a sampleCustomRetryCondition
class:public class CustomRetryCondition implements RetryCondition { public boolean shouldRetry(AmazonWebServiceRequest originalRequest, ...