Class EventStreamResponseHandlerFromBuilder<ResponseT,EventT>

java.lang.Object
software.amazon.awssdk.awscore.eventstream.EventStreamResponseHandlerFromBuilder<ResponseT,EventT>
Type Parameters:
ResponseT - Type of initial response object.
EventT - Type of event being published.
All Implemented Interfaces:
EventStreamResponseHandler<ResponseT,EventT>

public abstract class EventStreamResponseHandlerFromBuilder<ResponseT,EventT> extends Object implements EventStreamResponseHandler<ResponseT,EventT>
Base class for creating implementations of an EventStreamResponseHandler from a builder. See EventStreamResponseHandler.Builder.
  • Method Details

    • responseReceived

      public void responseReceived(ResponseT response)
      Description copied from interface: EventStreamResponseHandler
      Called when the initial response has been received and the POJO response has been unmarshalled. This is guaranteed to be called before EventStreamResponseHandler.onEventStream(SdkPublisher).

      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.

      Specified by:
      responseReceived in interface EventStreamResponseHandler<ResponseT,EventT>
      Parameters:
      response - Unmarshalled POJO containing metadata about the streamed data.
    • onEventStream

      public void onEventStream(SdkPublisher<EventT> p)
      Description copied from interface: EventStreamResponseHandler
      Called when events are ready to be streamed. Implementations must subscribe to the 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 NOT be treated as a failure of the response and the response will be completed normally.

      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.

      Specified by:
      onEventStream in interface EventStreamResponseHandler<ResponseT,EventT>
    • exceptionOccurred

      public void exceptionOccurred(Throwable throwable)
      Description copied from interface: EventStreamResponseHandler
      Called when an exception occurs while establishing the connection or streaming the response. Implementations should free up any resources in this method. This method may be called multiple times during the lifecycle of a request if automatic retries are enabled.
      Specified by:
      exceptionOccurred in interface EventStreamResponseHandler<ResponseT,EventT>
      Parameters:
      throwable - Exception that occurred.
    • complete

      public void complete()
      Description copied from interface: EventStreamResponseHandler
      Called when all data has been successfully published to the Subscriber. This will only be called once during the lifecycle of the request. Implementors should free up any resources they have opened.
      Specified by:
      complete in interface EventStreamResponseHandler<ResponseT,EventT>