Class BufferedSplittableAsyncRequestBody

java.lang.Object
software.amazon.awssdk.core.async.BufferedSplittableAsyncRequestBody
All Implemented Interfaces:
org.reactivestreams.Publisher<ByteBuffer>, AsyncRequestBody, SdkPublisher<ByteBuffer>

public final class BufferedSplittableAsyncRequestBody extends Object implements AsyncRequestBody
An AsyncRequestBody decorator that enables splitting into retryable sub-request bodies.

This wrapper allows any AsyncRequestBody to be split into multiple parts where each part can be retried independently. When split, each sub-body buffers its portion of data, enabling resubscription if a retry is needed (e.g., due to network failures or service errors).

Retry Requirements:

Retry is only possible if all the data has been successfully buffered during the first subscription. If the first subscriber fails to consume all the data (e.g., due to early cancellation or errors), subsequent retry attempts will fail since the complete data set is not available for resubscription.

Usage Example:

AsyncRequestBody originalBody = AsyncRequestBody.fromString("Hello World");
BufferedSplittableAsyncRequestBody retryableBody =
    BufferedSplittableAsyncRequestBody.create(originalBody);

Performance Considerations:

This implementation buffers data in memory to enable retries, but memory usage is controlled by the bufferSizeInBytes configuration. However, this buffering limits the ability to request more data from the original AsyncRequestBody until buffered data is consumed (i.e., when subscribers closes sub-body), which may increase latency compared to non-buffered implementations.

See Also: