ResponseT
- Initial response type of event stream operation.EventT
- Base type of event stream message frames.public class EventStreamAsyncResponseTransformer<ResponseT,EventT> extends Object implements AsyncResponseTransformer<SdkResponse,Void>
AsyncResponseTransformer
to decode event stream messages and deliver them to the
subscriber.Constructor and Description |
---|
EventStreamAsyncResponseTransformer(EventStreamResponseHandler<ResponseT,EventT> eventStreamResponseTransformer,
HttpResponseHandler<? extends ResponseT> initialResponseUnmarshaller,
HttpResponseHandler<? extends EventT> eventUnmarshaller,
HttpResponseHandler<? extends Throwable> exceptionUnmarshaller) |
Modifier and Type | Method and Description |
---|---|
Void |
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(SdkPublisher<ByteBuffer> publisher)
Called when events are ready to be streamed.
|
void |
responseReceived(SdkResponse response)
Called when the initial response has been received and the POJO response has
been unmarshalled.
|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
toBytes, toFile, toFile
public EventStreamAsyncResponseTransformer(EventStreamResponseHandler<ResponseT,EventT> eventStreamResponseTransformer, HttpResponseHandler<? extends ResponseT> initialResponseUnmarshaller, HttpResponseHandler<? extends EventT> eventUnmarshaller, HttpResponseHandler<? extends Throwable> exceptionUnmarshaller)
eventStreamResponseTransformer
- Response transformer provided by customer.initialResponseUnmarshaller
- Unmarshaller for the initial-response event stream message.eventUnmarshaller
- Unmarshaller for the various event types.public void responseReceived(SdkResponse response)
AsyncResponseTransformer
In the event of a retryable error, this callback may be called multiple times. It also may never be invoked if the request never succeeds.
responseReceived
in interface AsyncResponseTransformer<SdkResponse,Void>
response
- Unmarshalled POJO containing metadata about the streamed data.public void onStream(SdkPublisher<ByteBuffer> publisher)
AsyncResponseTransformer
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 AsyncResponseTransformer.exceptionOccurred(Throwable)
callback will be invoked.
This callback may never be called if the response has no content or if an error occurs.
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.
onStream
in interface AsyncResponseTransformer<SdkResponse,Void>
public void exceptionOccurred(Throwable throwable)
AsyncResponseTransformer
exceptionOccurred
in interface AsyncResponseTransformer<SdkResponse,Void>
throwable
- Exception that occurred.public Void complete()
AsyncResponseTransformer
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.complete
in interface AsyncResponseTransformer<SdkResponse,Void>
Copyright © 2017 Amazon Web Services, Inc. All Rights Reserved.