Class BufferedSplittableAsyncRequestBody
- All Implemented Interfaces:
org.reactivestreams.Publisher<ByteBuffer>,AsyncRequestBody,SdkPublisher<ByteBuffer>
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:
-
Nested Class Summary
Nested classes/interfaces inherited from interface software.amazon.awssdk.core.async.AsyncRequestBody
AsyncRequestBody.BodyType -
Method Summary
Modifier and TypeMethodDescriptionbody()Each AsyncRequestBody should return a well-formed name that can be used to identify the implementation.create(AsyncRequestBody delegate) Creates a newBufferedSplittableAsyncRequestBodythat wraps the providedAsyncRequestBody.splitCloseable(AsyncRequestBodySplitConfiguration splitConfiguration) Splits this request body into multiple retryable parts based on the provided configuration.voidsubscribe(org.reactivestreams.Subscriber<? super ByteBuffer> s) Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface software.amazon.awssdk.core.async.AsyncRequestBody
contentType, split, split, splitCloseableMethods inherited from interface software.amazon.awssdk.core.async.SdkPublisher
addTrailingData, buffer, doAfterOnCancel, doAfterOnComplete, doAfterOnError, filter, filter, flatMapIterable, limit, map, subscribe
-
Method Details
-
create
Creates a newBufferedSplittableAsyncRequestBodythat wraps the providedAsyncRequestBody.- Parameters:
delegate- theAsyncRequestBodyto wrap and make retryable. Must not be null.- Returns:
- a new
BufferedSplittableAsyncRequestBodyinstance - Throws:
NullPointerException- if delegate is null
-
contentLength
- Specified by:
contentLengthin interfaceAsyncRequestBody- Returns:
- The content length of the data being produced.
-
splitCloseable
public SdkPublisher<CloseableAsyncRequestBody> splitCloseable(AsyncRequestBodySplitConfiguration splitConfiguration) Splits this request body into multiple retryable parts based on the provided configuration.Each part returned by the publisher will be a
CloseableAsyncRequestBodythat buffers its portion of data, enabling resubscription for retry scenarios. This is the key difference from non-buffered splitting - each part can be safely retried without data loss.The splitting process respects the chunk size and buffer size specified in the configuration to optimize memory usage.
The subscriber MUST close each
CloseableAsyncRequestBodyto ensure resource is released- Specified by:
splitCloseablein interfaceAsyncRequestBody- Parameters:
splitConfiguration- configuration specifying how to split the request body- Returns:
- a publisher that emits retryable closable request body parts
- See Also:
-
subscribe
- Specified by:
subscribein interfaceorg.reactivestreams.Publisher<ByteBuffer>
-
body
Description copied from interface:AsyncRequestBodyEach AsyncRequestBody should return a well-formed name that can be used to identify the implementation. The body name should only include alphanumeric characters.- Specified by:
bodyin interfaceAsyncRequestBody- Returns:
- String containing the identifying name of this AsyncRequestBody implementation.
-