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 TypeMethodDescriptionvoidonContent(ByteBuffer buffer, boolean last, Callback callback) Callback method invoked by the producer when there is content available and there is demand for content.default voidCallback 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
callbackis associated with thebufferto signal when the content buffer has been consumed.Failing the
callbackdoes 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
InputStreamto produce content.- Parameters:
failure- the reason of the failure
-