Class ByteBuffersAsyncRequestBody
- All Implemented Interfaces:
AutoCloseable,org.reactivestreams.Publisher<ByteBuffer>,AsyncRequestBody,CloseableAsyncRequestBody,SdkPublisher<ByteBuffer>,SdkAutoCloseable
AsyncRequestBody for providing data from the supplied ByteBuffer array. This is created
using static methods on AsyncRequestBody
Subscription Behavior:
- Each subscriber receives a read-only view of the buffered data
- Subscribers receive data independently based on their own demand signaling
- If the body is closed, new subscribers will receive an error immediately
Resource Management:
The body should be closed when no longer needed to free buffered data and notify active subscribers. Closing the body will:- Clear all buffered data
- Send error notifications to all active subscribers
- Prevent new subscriptions
Splitting:
Because all data is already in memory, this implementation splits into independentByteBuffersAsyncRequestBody parts backed by read-only slices of the same data rather than using
SplittingPublisher making each part replayable.- 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.voidclose()static ByteBuffersAsyncRequestBodyfrom(byte[] bytes) static ByteBuffersAsyncRequestBodystatic ByteBuffersAsyncRequestBodyof(Long length, ByteBuffer... buffers) static ByteBuffersAsyncRequestBodyof(String mimetype, Long length, ByteBuffer... buffers) static ByteBuffersAsyncRequestBodyof(String mimetype, ByteBuffer... buffers) static ByteBuffersAsyncRequestBodyof(ByteBuffer... buffers) static ByteBuffersAsyncRequestBodyof(List<ByteBuffer> buffers) static ByteBuffersAsyncRequestBodyof(List<ByteBuffer> buffers, long length) split(AsyncRequestBodySplitConfiguration splitConfiguration) Converts thisAsyncRequestBodyto a publisher ofAsyncRequestBodys, each of which publishes a specific portion of the original data, based on the providedAsyncRequestBodySplitConfiguration.splitCloseable(AsyncRequestBodySplitConfiguration splitConfiguration) Converts thisAsyncRequestBodyto a publisher ofCloseableAsyncRequestBodys, each of which publishes specific portion of the original data, based on the providedAsyncRequestBodySplitConfiguration.voidsubscribe(org.reactivestreams.Subscriber<? super ByteBuffer> subscriber) 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
split, splitCloseableMethods inherited from interface software.amazon.awssdk.core.async.SdkPublisher
addTrailingData, buffer, doAfterOnCancel, doAfterOnComplete, doAfterOnError, filter, filter, flatMapIterable, limit, map, subscribe
-
Method Details
-
contentLength
- Specified by:
contentLengthin interfaceAsyncRequestBody- Returns:
- The content length of the data being produced.
-
contentType
- Specified by:
contentTypein interfaceAsyncRequestBody- Returns:
- The content type of the data being produced.
-
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.
-
split
Converts thisAsyncRequestBodyto a publisher ofAsyncRequestBodys, each of which publishes a specific portion of the original data, based on the providedAsyncRequestBodySplitConfiguration. The default chunk size is 2MB and the default buffer size is 8MB.By default, if content length of this
AsyncRequestBodyis present, each dividedAsyncRequestBodyis delivered to the subscriber right after it's initialized. On the other hand, if content length is null, it is sent after the entire content for that chunk is buffered. In this case, the configuredmaxMemoryUsageInBytesmust be larger than or equal tochunkSizeInBytes. Note that this behavior may be different if a specific implementation of this interface overrides this method.Behaves the same as
splitCloseable(AsyncRequestBodySplitConfiguration); the emitted parts are closeable, even though they are exposed here as plainAsyncRequestBodys.- Specified by:
splitin interfaceAsyncRequestBody
-
splitCloseable
public SdkPublisher<CloseableAsyncRequestBody> splitCloseable(AsyncRequestBodySplitConfiguration splitConfiguration) Converts thisAsyncRequestBodyto a publisher ofCloseableAsyncRequestBodys, each of which publishes specific portion of the original data, based on the providedAsyncRequestBodySplitConfiguration. The default chunk size is 2MB and the default buffer size is 8MB.The default implementation behaves the same as
AsyncRequestBody.split(AsyncRequestBodySplitConfiguration). This behavior may vary in different implementations.Caller is responsible for closing
CloseableAsyncRequestBodywhen it is ready to be disposed to release any resources.Note: This method is primarily intended for use by AWS SDK high-level libraries and internal components. SDK customers should typically use higher-level APIs provided by service clients rather than calling this method directly.
Each part is an independent, replayable
ByteBuffersAsyncRequestBodybacked by read-only slices of this body's data, so no data is copied and each part may be subscribed to more than once (i.e. it supports retries). Closing a part releases only that part's slices; it does not affect this body or any sibling part.AsyncRequestBodySplitConfiguration.bufferSizeInBytes()is not applicable here and is ignored, since all of the data is already buffered in memory.- Specified by:
splitCloseablein interfaceAsyncRequestBody- See Also:
-
of
-
of
-
of
-
of
-
of
-
of
-
from
-
from
-
close
public void close()Description copied from interface:SdkAutoCloseable- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceSdkAutoCloseable
-
bufferedData
-