Reactive Streams in Java by Adam L. Davis

Reactive Streams in Java by Adam L. Davis

Author:Adam L. Davis
Language: eng
Format: epub
ISBN: 9781484241769
Publisher: Apress


A BroadcastHub can be used to consume elements from a common producer by a dynamic set of consumers.

A PartitionHub can be used to route elements from a common producer to a dynamic set of consumers. The selection of consumer is done with a function and each element can only be routed to one consumer.

For example, here is a simple use case of a MergeHub:Sink<String, CompletionStage<Done>> consumer =

Sink.foreach(System.out::println); //1

int bufferSize = 8;

RunnableGraph<Sink<String, NotUsed>> runnableGraph =

MergeHub.of(String.class, bufferSize)

.to(consumer); //2

Sink<String, NotUsed> toConsumer =

runnableGraph.run(materializer); //3



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.