javav2/example_code/dynamodb/adaptive_retry_docs/migration-guide.md
This guide provides step-by-step instructions for migrating from AWS SDK's standard retry policies to AdaptiveRetryStrategy. The adaptive retry strategy includes client-side rate limiting and dynamic backoff based on current load conditions.
⚠️ Important: AdaptiveRetryStrategy is designed for use cases with high resource constraints and assumes single-resource clients. For most applications, AWS recommends using
StandardRetryStrategyinstead. Consider AdaptiveRetryStrategy only if you have specific throttling challenges and can ensure single-resource client usage.
⚠️ Single Resource Assumption: AdaptiveRetryStrategy assumes the client works against a single resource (e.g., one DynamoDB table or one S3 bucket). If you use a single client for multiple resources, throttling or outages with one resource can affect all other resources.
⚠️ Recommendation: AWS recommends using StandardRetryStrategy for most use cases, as it is "generally useful across all retry use cases" unlike AdaptiveRetryStrategy which is specialized for resource-constrained scenarios.
First, locate your existing retry policy configuration. Common patterns include:
Standard Retry Policy Example:
// Current standard retry configuration
RetryPolicy retryPolicy = RetryPolicy.builder()
.numRetries(3)
.retryCondition(RetryCondition.defaultRetryCondition())
.backoffStrategy(BackoffStrategy.defaultStrategy())
.throttlingBackoffStrategy(BackoffStrategy.defaultThrottlingStrategy())
.build();
DynamoDbClient client = DynamoDbClient.builder()
.overrideConfiguration(ClientOverrideConfiguration.builder()
.retryPolicy(retryPolicy)
.build())
.build();
Convert your standard retry policy to AdaptiveRetryStrategy:
AdaptiveRetryStrategy Equivalent:
// Simplest approach: Use RetryMode.ADAPTIVE
DynamoDbClient client = DynamoDbClient.builder()
.overrideConfiguration(ClientOverrideConfiguration.builder()
.retryStrategy(software.amazon.awssdk.core.retry.RetryMode.ADAPTIVE)
.build())
.build();
// Or using builder pattern for custom configuration
AdaptiveRetryStrategy adaptiveRetryStrategy = AdaptiveRetryStrategy.builder()
.maxAttempts(4) // numRetries(3) + 1 initial attempt = 4 total attempts
.backoffStrategy(BackoffStrategy.exponentialDelay(
Duration.ofMillis(100), // base delay
Duration.ofSeconds(20) // max delay
))
.throttlingBackoffStrategy(BackoffStrategy.exponentialDelay(
Duration.ofSeconds(1), // base delay for throttling
Duration.ofSeconds(20) // max delay for throttling
))
// Note: circuitBreakerEnabled() method doesn't exist - circuit breaking is built-in
.build();
DynamoDbClient client = DynamoDbClient.builder()
.overrideConfiguration(ClientOverrideConfiguration.builder()
.retryStrategy(adaptiveRetryStrategy)
.build())
.build();
Use this table to map your existing retry policy parameters to AdaptiveRetryStrategy equivalents:
| Standard Retry Policy | AdaptiveRetryStrategy | Notes |
|---|---|---|
numRetries(n) | maxAttempts(n+1) | Add 1 to account for initial attempt |
retryCondition() | Built-in adaptive logic | AdaptiveRetryStrategy handles this automatically |
backoffStrategy() | Built-in adaptive backoff | Uses intelligent backoff based on error patterns |
throttlingBackoffStrategy() | Built-in throttling handling | Automatically adapts to throttling scenarios |
If you have custom retry configurations, here's how to migrate them:
Before - Custom Standard Retry:
RetryPolicy customRetryPolicy = RetryPolicy.builder()
.numRetries(5)
.retryCondition(RetryCondition.defaultRetryCondition()
.and(context -> context.exception() instanceof DynamoDbException))
.backoffStrategy(BackoffStrategy.exponentialDelay(Duration.ofMillis(100), Duration.ofSeconds(10)))
.build();
After - Custom AdaptiveRetryStrategy:
// AdaptiveRetryStrategy allows custom backoff configuration
AdaptiveRetryStrategy customAdaptiveStrategy = AdaptiveRetryStrategy.builder()
.maxAttempts(6) // 5 retries + 1 initial = 6 total attempts
.backoffStrategy(BackoffStrategy.exponentialDelay(
Duration.ofMillis(200), // custom base delay
Duration.ofSeconds(30) // increased max delay
))
.throttlingBackoffStrategy(BackoffStrategy.exponentialDelay(
Duration.ofMillis(500), // longer base delay for throttling
Duration.ofMinutes(1) // extended max delay for throttling
))
// Note: circuitBreakerEnabled() is not available - circuit breaking is built into adaptive strategy
.build();
After migration, validate your new configuration:
Example Validation Code:
// Test your new adaptive retry configuration
@Test
public void testAdaptiveRetryMigration() {
AdaptiveRetryStrategy strategy = AdaptiveRetryStrategy.builder()
.maxAttempts(4)
.build();
DynamoDbClient client = DynamoDbClient.builder()
.overrideConfiguration(ClientOverrideConfiguration.builder()
.retryStrategy(strategy)
.build())
.build();
// Perform operations and verify retry behavior
assertNotNull(client);
}
When migrating to AdaptiveRetryStrategy, be aware of these critical API differences:
// WRONG - SDK v1 style packages
import software.amazon.awssdk.core.retry.RetryPolicy;
import software.amazon.awssdk.core.retry.backoff.BackoffStrategy;
// CORRECT - SDK v2 packages
import software.amazon.awssdk.retries.AdaptiveRetryStrategy;
import software.amazon.awssdk.retries.api.BackoffStrategy;
// WRONG - RetryPolicy.builder() is deprecated
RetryPolicy retryPolicy = RetryPolicy.builder()
.numRetries(3)
.circuitBreakerEnabled(true) // This method doesn't exist in AdaptiveRetryStrategy
.build();
// CORRECT - AdaptiveRetryStrategy.builder()
AdaptiveRetryStrategy adaptiveRetryStrategy = AdaptiveRetryStrategy.builder()
.maxAttempts(3)
// Note: circuitBreakerEnabled() method doesn't exist - circuit breaking is built-in
.build();
// WRONG - .retryPolicy() doesn't exist in SDK v2
.overrideConfiguration(builder -> builder.retryPolicy(retryPolicy))
// CORRECT - Use .retryStrategy()
.overrideConfiguration(ClientOverrideConfiguration.builder()
.retryStrategy(adaptiveRetryStrategy)
.build())
// WRONG - retryMode() method signature is incorrect
.retryMode(software.amazon.awssdk.core.retry.RetryMode.ADAPTIVE)
// CORRECT - Use retryStrategy() with RetryMode
.retryStrategy(software.amazon.awssdk.core.retry.RetryMode.ADAPTIVE)
| Error | Cause | Fix |
|---|---|---|
cannot find symbol: method circuitBreakerEnabled(boolean) | Method doesn't exist in AdaptiveRetryStrategy | Remove - circuit breaking is built-in |
method retryMode(...) cannot be applied to given types | Wrong method signature | Use .retryStrategy(RetryMode.ADAPTIVE) |
cannot find symbol: method retryPolicy(...) | Method doesn't exist in SDK v2 | Use .retryStrategy(...) |
RetryPolicy import errors | Using deprecated v1-style API | Import AdaptiveRetryStrategy instead |
Before:
DynamoDbClient client = DynamoDbClient.builder()
.overrideConfiguration(ClientOverrideConfiguration.builder()
.retryPolicy(RetryPolicy.builder()
.numRetries(2)
.build())
.build())
.build();
After:
// Simplest approach using RetryMode
DynamoDbClient client = DynamoDbClient.builder()
.overrideConfiguration(ClientOverrideConfiguration.builder()
.retryStrategy(software.amazon.awssdk.core.retry.RetryMode.ADAPTIVE)
.build())
.build();
// Or with custom max attempts using AdaptiveRetryStrategy.builder()
AdaptiveRetryStrategy strategy = AdaptiveRetryStrategy.builder()
.maxAttempts(3)
.build();
DynamoDbClient client = DynamoDbClient.builder()
.overrideConfiguration(ClientOverrideConfiguration.builder()
.retryStrategy(strategy)
.build())
.build();
Before:
RetryPolicy highThroughputRetry = RetryPolicy.builder()
.numRetries(1) // Minimal retries for speed
.backoffStrategy(BackoffStrategy.fixedDelay(Duration.ofMillis(50)))
.build();
After:
// AdaptiveRetryStrategy allows custom backoff configuration
AdaptiveRetryStrategy highThroughputAdaptive = AdaptiveRetryStrategy.builder()
.maxAttempts(2) // 1 retry + 1 initial attempt
.backoffStrategy(BackoffStrategy.exponentialDelay(
Duration.ofMillis(50), // fast base delay
Duration.ofSeconds(5) // shorter max delay
))
.build();
Before:
RetryPolicy batchRetry = RetryPolicy.builder()
.numRetries(5) // More retries for batch operations
.backoffStrategy(BackoffStrategy.exponentialDelay(Duration.ofSeconds(1), Duration.ofMinutes(1)))
.build();
After:
// AdaptiveRetryStrategy with custom configuration for batch operations
AdaptiveRetryStrategy batchAdaptive = AdaptiveRetryStrategy.builder()
.maxAttempts(6) // 5 retries + 1 initial attempt
.backoffStrategy(BackoffStrategy.exponentialDelay(
Duration.ofSeconds(1), // longer base delay for batch
Duration.ofMinutes(1) // extended max delay
))
.throttlingBackoffStrategy(BackoffStrategy.exponentialDelay(
Duration.ofSeconds(2), // even longer for throttling
Duration.ofMinutes(2) // extended throttling delay
))
.build();
Issue 1: Compilation Errors - Method Not Found
cannot find symbol: method circuitBreakerEnabled(boolean).circuitBreakerEnabled() calls - circuit breaking is built into AdaptiveRetryStrategy by defaultIssue 2: Compilation Errors - Wrong Method Signature
method retryMode(...) cannot be applied to given types.retryStrategy(RetryMode.ADAPTIVE) instead of .retryMode(RetryMode.ADAPTIVE)Issue 3: Compilation Errors - Method Not Found
cannot find symbol: method retryPolicy(...).retryPolicy() with .retryStrategy() in ClientOverrideConfigurationIssue 4: Import Errors
RetryPolicy not found or deprecated warningssoftware.amazon.awssdk.retries.AdaptiveRetryStrategy and related classesIssue 5: Different Retry Behavior
maxAttempts and timing parametersIssue 6: Performance Changes
software.amazon.awssdk.retries.* packagesRetryPolicy.builder() with AdaptiveRetryStrategy.builder()retryPolicy() with retryStrategy() in ClientOverrideConfiguration.circuitBreakerEnabled() calls (built into AdaptiveRetryStrategy)numRetries to maxAttempts (adding 1).retryMode() calls to use .retryStrategy(RetryMode.ADAPTIVE)After completing the migration:
For more detailed configuration options, see the Configuration Reference. For advanced usage patterns, see the Integration Patterns.
This migration guide is based on official AWS SDK for Java 2.x documentation and best practices:
AWS SDK for Java 2.x Developer Guide - Configure retry behavior
AWS Documentation
https://docs.aws.amazon.com/sdk-for-java/latest/developer-guide/retry-strategy.html
Retrieved: August 18, 2025
AWS SDK for Java 2.x API Reference - AdaptiveRetryStrategy
AWS SDK API Documentation
https://sdk.amazonaws.com/java/api/latest/software/amazon/awssdk/retries/AdaptiveRetryStrategy.html
Retrieved: August 18, 2025
AWS SDK for Java 2.x API Reference - RetryPolicy (Deprecated)
AWS SDK API Documentation
https://sdk.amazonaws.com/java/api/latest/software/amazon/awssdk/core/retry/RetryPolicy.html
Retrieved: August 18, 2025
The migration examples and parameter mappings in this guide are derived from the official AWS documentation patterns and the documented default values for each retry strategy type. All code examples follow the patterns established in the AWS SDK for Java 2.x Developer Guide.
Citations: