Interface Request.Content.Consumer

Enclosing interface:
Request.Content

public static interface Request.Content.Consumer

A reactive model to consume request content, similar to Flow.Subscriber.

Callback methods onContent(ByteBuffer, boolean, Callback) and onFailure(Throwable) are invoked in strict sequential order and never concurrently, although possibly by different threads.

  • Method Summary

    Modifier and Type
    Method
    Description
    void
    onContent(ByteBuffer buffer, boolean last, Callback callback)
    Callback method invoked by the producer when there is content available and there is demand for content.
    default void
    Callback method invoked by the producer when it failed to produce content.
  • Method Details

    • onContent

      void onContent(ByteBuffer buffer, boolean last, Callback callback)

      Callback method invoked by the producer when there is content available and there is demand for content.

      The callback is associated with the buffer to signal when the content buffer has been consumed.

      Failing the callback does not have any effect on content production. To stop the content production, the consumer must call Request.Content.Subscription.fail(Throwable).

      In case an exception is thrown by this method, it is equivalent to a call to Request.Content.Subscription.fail(Throwable).

      Parameters:
      buffer - the content buffer to consume
      last - whether it's the last content
      callback - a callback to invoke when the content buffer is consumed
    • onFailure

      default void onFailure(Throwable failure)

      Callback method invoked by the producer when it failed to produce content.

      Typical failure: a producer getting an exception while reading from an InputStream to produce content.

      Parameters:
      failure - the reason of the failure