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 newBufferedSplittableAsyncRequestBody
that wraps the providedAsyncRequestBody
.splitCloseable
(AsyncRequestBodySplitConfiguration splitConfiguration) Splits this request body into multiple retryable parts based on the provided configuration.void
subscribe
(org.reactivestreams.Subscriber<? super ByteBuffer> s) Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface software.amazon.awssdk.core.async.AsyncRequestBody
contentType, split, split, splitCloseable
Methods 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 newBufferedSplittableAsyncRequestBody
that wraps the providedAsyncRequestBody
.- Parameters:
delegate
- theAsyncRequestBody
to wrap and make retryable. Must not be null.- Returns:
- a new
BufferedSplittableAsyncRequestBody
instance - Throws:
NullPointerException
- if delegate is null
-
contentLength
- Specified by:
contentLength
in 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
CloseableAsyncRequestBody
that 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
CloseableAsyncRequestBody
to ensure resource is released- Specified by:
splitCloseable
in 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:
subscribe
in interfaceorg.reactivestreams.Publisher<ByteBuffer>
-
body
Description copied from interface:AsyncRequestBody
Each 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:
body
in interfaceAsyncRequestBody
- Returns:
- String containing the identifying name of this AsyncRequestBody implementation.
-