Class Broadcast<T>

All Implemented Interfaces:
Graph<UniformFanOutShape<T,T>,NotUsed>, TypePreservingFanOut

public final class Broadcast<T> extends GraphStage<UniformFanOutShape<T,T>> implements TypePreservingFanOut
Fan-out the stream to several streams emitting each incoming upstream element to all downstream consumers. It will not shut down until the subscriptions for at least two downstream subscribers have been established.

'''Emits when''' all of the outputs stops backpressuring and there is an input element available

'''Backpressures when''' any of the outputs backpressure

'''Completes when''' upstream completes

'''Cancels when''' If eagerCancel is enabled: when any downstream cancels; otherwise: when all downstreams cancel

  • Constructor Details

    • Broadcast

      public Broadcast(int outputPorts, boolean eagerCancel)
    • Broadcast

      public Broadcast(int outputPorts, boolean eagerCancel, scala.collection.immutable.Set<Object> nonEagerCancelOutputs)
      Create a new Broadcast with per-output cancellation behavior.

      Parameters:
      nonEagerCancelOutputs - set of output port indices whose cancellation should not trigger upstream cancellation when eagerCancel is true. These outputs are silently removed from the broadcast when they cancel, and elements continue flowing to the remaining outputs. Must be empty when eagerCancel is false (where the parameter would be meaningless).
      Since:
      2.0.0
  • Method Details

    • apply

      public static <T> Broadcast<T> apply(int outputPorts, boolean eagerCancel)
      Create a new Broadcast with the specified number of output ports.

      Parameters:
      outputPorts - number of output ports
      eagerCancel - if true, broadcast cancels upstream if any of its downstreams cancel.
    • apply

      public static <T> Broadcast<T> apply(int outputPorts, boolean eagerCancel, scala.collection.immutable.Set<Object> nonEagerCancelOutputs)
      Create a new Broadcast with the specified number of output ports and per-output cancellation behavior.

      Parameters:
      outputPorts - number of output ports
      eagerCancel - if true, broadcast cancels upstream if any of its downstreams cancel (except those listed in nonEagerCancelOutputs).
      nonEagerCancelOutputs - set of output port indices whose cancellation should not trigger upstream cancellation. These outputs are silently removed from the broadcast when they cancel, and elements continue flowing to the remaining outputs.
      Since:
      2.0.0
    • apply$default$2

      public static <T> boolean apply$default$2()
    • outputPorts

      public int outputPorts()
    • eagerCancel

      public boolean eagerCancel()
    • nonEagerCancelOutputs

      public scala.collection.immutable.Set<Object> nonEagerCancelOutputs()
      Set of output port indices whose cancellation should not trigger upstream cancellation. Only meaningful when eagerCancel is true; these outputs are silently removed from the broadcast when they cancel, and elements continue flowing to the remaining outputs.

      Since:
      2.0.0
    • in

      public Inlet<T> in()
    • out

      public scala.collection.immutable.IndexedSeq<Outlet<T>> out()
    • initialAttributes

      public Attributes initialAttributes()
      Overrides:
      initialAttributes in class GraphStageWithMaterializedValue<UniformFanOutShape<T,T>,NotUsed>
    • shape

      public UniformFanOutShape<T,T> shape()
      Description copied from interface: Graph
      The shape of a graph is all that is externally visible: its inlets and outlets.
      Specified by:
      shape in interface Graph<UniformFanOutShape<T,T>,NotUsed>
    • createLogic

      public GraphStageLogic createLogic(Attributes inheritedAttributes)
      Specified by:
      createLogic in class GraphStage<UniformFanOutShape<T,T>>
    • toString

      public String toString()
      Overrides:
      toString in class Object