ResponseT
- POJO response type.ReturnT
- Type this response handler produces. I.E. the type you are transforming the response into.public interface AsyncResponseHandler<ResponseT,ReturnT>
Modifier and Type | Method | Description |
---|---|---|
ReturnT |
complete() |
Called when all data has been successfully published to the
Subscriber . |
void |
exceptionOccurred(Throwable throwable) |
Called when an exception occurs while establishing the connection or streaming the response.
|
void |
onStream(org.reactivestreams.Publisher<ByteBuffer> publisher) |
Called when the HTTP client is ready to start sending data to the response handler.
|
void |
responseReceived(ResponseT response) |
Called when the initial response (headers/status code) has been received and the POJO response has
been unmarshalled.
|
static <ResponseT> |
toFile(Path path) |
Creates an
AsyncResponseHandler that writes all the content to the given file. |
void responseReceived(ResponseT response)
response
- Unmarshalled POJO containing metadata about the streamed data.void onStream(org.reactivestreams.Publisher<ByteBuffer> publisher)
Publisher
and request data via a Subscription
as
they can handle it.
If at any time the subscriber wishes to stop receiving data, it may call Subscription.cancel()
. This
will be treated as a failure of the response and the exceptionOccurred(Throwable)
callback will be invoked.
In the event of a retryable error, this callback may be called multiple times with different Publishers. If this method is called more than once, implementation must either reset any state to prepare for another stream of data or must throw an exception indicating they cannot reset. If any exception is thrown then no automatic retry is performed.
void exceptionOccurred(Throwable throwable)
throwable
- Exception that occurred.ReturnT complete()
Subscriber
. This will
only be called once during the lifecycle of the request. Implementors should free up any resources they have
opened and do final transformations to produce the return object.static <ResponseT> AsyncResponseHandler<ResponseT,Void> toFile(Path path)
AsyncResponseHandler
that writes all the content to the given file. In the event of an error,
the SDK will attempt to delete the file (whatever has been written to it so far). If the file already exists, an
exception will be thrown.ResponseT
- Pojo Response type.path
- Path to file to write to.Copyright © 2017 Amazon Web Services, Inc. All Rights Reserved.