Interface AsyncResponseTransformer<ResponseT,ResultT>

Type Parameters:
ResponseT - POJO response type.
ResultT - Type this response handler produces. I.E. the type you are transforming the response into.
All Known Implementing Classes:
AsyncResponseTransformerListener.NotifyingAsyncResponseTransformer, ByteArrayAsyncResponseTransformer, EventStreamAsyncResponseTransformer, FileAsyncResponseTransformer, InputStreamResponseTransformer, PublisherAsyncResponseTransformer, RestEventStreamAsyncResponseTransformer

public interface AsyncResponseTransformer<ResponseT,ResultT>
Callback interface to handle a streaming asynchronous response.

Synchronization

All operations, including those called on the Subscriber of the stream are guaranteed to be synchronized externally; i.e. no two methods on this interface or on the Subscriber will be invoked concurrently. It is not guaranteed that the methods will being invoked by the same thread.

Invocation Order

The methods are called in the following order:

  • prepare(): This method is always called first. Implementations should use this to setup or perform any cleanup necessary. Note that this will be called upon each request attempt. If the CompletableFuture returned from the previous invocation has already been completed, the implementation should return a new instance.
  • onResponse(ResponseT): If the response was received successfully, this method is called next.
  • onStream(SdkPublisher): Called after onResponse. This is always invoked, even if the service operation response does not contain a body. If the response does not have a body, then the SdkPublisher will complete the subscription without signaling any elements.
  • exceptionOccurred(Throwable): If there is an error sending the request. This method is called before Subscriber.onError(Throwable).
  • Subscriber.onError(Throwable): If an error is encountered while the Publisher is publishing to a Subscriber.

Retries

The transformer has the ability to trigger retries at any time by completing the CompletableFuture with an exception that is deemed retryable by the configured RetryPolicy.