Interface Request.Content.Consumer
- Enclosing interface:
- Request.Content
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 TypeMethodDescriptionvoid
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
Callback method invoked by the producer when there is content available and there is demand for content.
The
callback
is associated with thebuffer
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 callRequest.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 consumelast
- whether it's the last contentcallback
- a callback to invoke when the content buffer is consumed
-
onFailure
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
-