This is a reactive streams implementation based on the Servlet 3.1 asynchronous IO API. It has zero dependencies, other than the JDK. It is TCK verified.
To create a publisher for a request (which can be subscribed to to consume the request body):
HttpServletRequest request = ...
AsyncContext context = request.startAsync();
Publisher<ByteBuffer> publisher = new RequestPublisher(context, 8192);
The second parameter to RequestPubisher
is the maximum amount of data to read on each attempt to read.
To create a subscriber for a response (which can be passed to a publisher to publish the response body):
HttpServletRequest request = ...
AsyncContext context = request.startAsync();
Subscriber<ByteBuffer> subscriber = new ResponseSubscriber(context);
Currently, the response subscriber only requests one element at a time, and never buffers. This could be improved, for example, using a low and high watermark based buffer, to keep a few elements in flight for maximising throughput.
This project has been produced by Lightbend. The code is offered to the Public Domain in order to allow free use by interested parties who want to create compatible implementations. For details see COPYING
.
To the extent possible under law,
Reactive Streams Special Interest Group
has waived all copyright and related or neighboring rights to
Reactive Streams JVM.
This work is published from:
United States.