Class BroadcastHub<T>
- java.lang.Object
-
- akka.stream.stage.GraphStageWithMaterializedValue<SinkShape<T>,Source<T,NotUsed>>
-
- akka.stream.scaladsl.BroadcastHub<T>
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
BroadcastHub.ConsumerEvent
static interface
BroadcastHub.HubEvent
static interface
BroadcastHub.HubState
-
Nested classes/interfaces inherited from interface akka.stream.Graph
Graph.GraphMapMatVal<S extends Shape,M>
-
-
Constructor Summary
Constructors Constructor Description BroadcastHub(int bufferSize)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description scala.Tuple2<GraphStageLogic,Source<T,NotUsed>>
createLogicAndMaterializedValue(Attributes inheritedAttributes)
Inlet<T>
in()
SinkShape<T>
shape()
The shape of a graph is all that is externally visible: its inlets and outlets.static <T> Sink<T,Source<T,NotUsed>>
sink()
Creates aSink
that receives elements from its upstream producer and broadcasts them to a dynamic set of consumers.static <T> Sink<T,Source<T,NotUsed>>
sink(int bufferSize)
Creates aSink
that receives elements from its upstream producer and broadcasts them to a dynamic set of consumers.-
Methods inherited from class akka.stream.stage.GraphStageWithMaterializedValue
createLogicAndMaterializedValue, initialAttributes, traversalBuilder, withAttributes
-
-
-
-
Method Detail
-
sink
public static <T> Sink<T,Source<T,NotUsed>> sink(int bufferSize)
Creates aSink
that receives elements from its upstream producer and broadcasts them to a dynamic set of consumers. After theSink
returned by this method is materialized, it returns aSource
as materialized value. ThisSource
can be materialized an arbitrary number of times and each materialization will receive the broadcast elements from the originalSink
.Every new materialization of the
Sink
results in a new, independent hub, which materializes to its ownSource
for consuming theSink
of that materialization.If the original
Sink
is failed, then the failure is immediately propagated to all of its materializedSource
s (possibly jumping over already buffered elements). If the originalSink
is completed, then all correspondingSource
s are completed. Both failure and normal completion is "remembered" and later materializations of theSource
will see the same (failure or completion) state.Source
s that are cancelled are simply removed from the dynamic set of consumers.- Parameters:
bufferSize
- Buffer size used by the producer. Gives an upper bound on how "far" from each other two concurrent consumers can be in terms of element. If this buffer is full, the producer is backpressured. Must be a power of two and less than 4096.
-
sink
public static <T> Sink<T,Source<T,NotUsed>> sink()
Creates aSink
that receives elements from its upstream producer and broadcasts them to a dynamic set of consumers. After theSink
returned by this method is materialized, it returns aSource
as materialized value. ThisSource
can be materialized arbitrary many times and each materialization will receive the broadcast elements from the originalSink
.Every new materialization of the
Sink
results in a new, independent hub, which materializes to its ownSource
for consuming theSink
of that materialization.If the original
Sink
is failed, then the failure is immediately propagated to all of its materializedSource
s (possibly jumping over already buffered elements). If the originalSink
is completed, then all correspondingSource
s are completed. Both failure and normal completion is "remembered" and later materializations of theSource
will see the same (failure or completion) state.Source
s that are cancelled are simply removed from the dynamic set of consumers.
-
shape
public SinkShape<T> shape()
Description copied from interface:Graph
The shape of a graph is all that is externally visible: its inlets and outlets.
-
createLogicAndMaterializedValue
public scala.Tuple2<GraphStageLogic,Source<T,NotUsed>> createLogicAndMaterializedValue(Attributes inheritedAttributes)
- Specified by:
createLogicAndMaterializedValue
in classGraphStageWithMaterializedValue<SinkShape<T>,Source<T,NotUsed>>
-
-