How to implement and test retry option with S3CrtRetryConfiguration

I’ve a Spring Boot application integrated with AWS SDK written in Java. Also, the project uses Gradle as the build tool.

build.gradle:

dependencies {
    ......
    .........
    implementation 'software.amazon.awssdk.crt:aws-crt:0.24.0'
    implementation 'software.amazon.awssdk:s3-transfer-manager:2.20.119'
}

Now, I’ve the below code to generate S3AsyncClient with S3CrtRetryConfiguration.

S3CrtAsyncClientBuilder s3CrtAsyncClientBuilder = S3AsyncClient.crtBuilder()
            .credentialsProvider(creds).region(region);
S3CrtRetryConfiguration s3CrtRetryConfiguration = S3CrtRetryConfiguration.builder()
            .numRetries(s3UploadMaxRetries).build();
s3CrtAsyncClientBuilder.retryConfiguration(s3CrtRetryConfiguration);
S3AsyncClient s3CrtAsyncClient = s3CrtAsyncClientBuilder.build();

Problem: When I upload a file using this client, the code should retry for any failure. But I don’t see any retry being triggered when a failure is happening.

Is it something that I missed in the configuration which needs to be added to make this work? Please suggest.

AWS provides different strategies for retrying errors. The AWS documentation describes them in detail, although there are subtle differences for the different SDK, tools and languages. Please, consider review the relevant documentation for the Java SDK.

With that in mind, I think you are providing the right configuration in your code:

S3CrtRetryConfiguration s3CrtRetryConfiguration = S3CrtRetryConfiguration.builder()
            .numRetries(s3UploadMaxRetries).build();
s3CrtAsyncClientBuilder.retryConfiguration(s3CrtRetryConfiguration);

As you can see in the source code of DefaultS3CrtAsyncClient, this configuration will be used to configure the underlying retry mechanism (as the stndard one, with exponential backoff based on the number of retries configured):

if (builder.retryConfiguration != null) {
  nativeClientBuilder.standardRetryOptions(
    new StandardRetryOptions()
      .withBackoffRetryOptions(
        new ExponentialBackoffRetryOptions()
          .withMaxRetries(
            builder.retryConfiguration.numRetries())));
}

Please, be aware that, by default, the AWS SDK will retry only under certain HTTP error codes and conditions:

static {
    Set<Integer> retryableStatusCodes = new HashSet<>();
    retryableStatusCodes.add(HttpStatusCode.INTERNAL_SERVER_ERROR);
    retryableStatusCodes.add(HttpStatusCode.BAD_GATEWAY);
    retryableStatusCodes.add(HttpStatusCode.SERVICE_UNAVAILABLE);
    retryableStatusCodes.add(HttpStatusCode.GATEWAY_TIMEOUT);
    RETRYABLE_STATUS_CODES = unmodifiableSet(retryableStatusCodes);


    Set<Class<? extends Exception>> retryableExceptions = new HashSet<>();
    retryableExceptions.add(RetryableException.class);
    retryableExceptions.add(IOException.class);
    retryableExceptions.add(UncheckedIOException.class);
    retryableExceptions.add(ApiCallAttemptTimeoutException.class);
    RETRYABLE_EXCEPTIONS = unmodifiableSet(retryableExceptions);
}

I am not certain in the case of CRT but, in general, you can in addition tweak this retry behavior and add certain error codes or exceptions you want to retry on.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật