https://grokonez.com/java/java-9/java-9-flow-api-example-processor
Java 9 Flow API example – Processor
In previous post, we have general knowledge about Reactive Streams and Java 9 Flow API Components and Behaviour. In this tutorial, we’re gonna look at an example that implements Publisher, Subscriber with Processor as a bridge for reactive programming.
Related Articles:
We can create one or more Processors in chain which link a Publisher to a Subscriber.
Using Subscriber::onNext()
method, Publisher pushes items to Processor, and Processor pushes items to Subscriber.
Using Subscription::request()
method, Processor requests items from Publisher, and Subscriber requests items from Processor.
Publisher and Processor defines an Executor for multi-threading. Then request()
and onNext()
method work asynchronously.
Processor has a data buffer to store items in case the demand number of items requested by Subscriber and Processor are different.
Publisher<Integer> ------ Processor<Integer, String> ------ Subscriber<String>
More at:
https://grokonez.com/java/java-9/java-9-flow-api-example-processor
Java 9 Flow API example – Processor
#java #java9 #flow #processor