Class MultiBroadcast<T>

java.lang.Object
io.smallrye.mutiny.groups.MultiBroadcast<T>
Type Parameters:
T - the type of item

public class MultiBroadcast<T> extends Object
Makes the upstream Multi be able to broadcast its events (items, failure, and completion) to multiple subscribers.

Broadcast transforms the upstream into a hot streams meaning that late subscriber won't see all the events.

  • Constructor Details

    • MultiBroadcast

      public MultiBroadcast(Multi<T> upstream)
  • Method Details

    • toAllSubscribers

      @CheckReturnValue public Multi<T> toAllSubscribers()
      Broadcasts the events of the upstream Multi to all the subscribers. Subscribers start receiving the events as soon as they subscribe.
      Returns:
      the Multi accepting several subscribers
    • toAtLeast

      @CheckReturnValue public Multi<T> toAtLeast(int numberOfSubscribers)
      Broadcasts the events of the upstream Multi to several subscribers. Subscribers start receiving the events when at least numberOfSubscribers subscribes to the produced Multi.
      Parameters:
      numberOfSubscribers - the number of subscriber requires before subscribing to the upstream multi and start dispatching the events. Must be strictly positive.
      Returns:
      the Multi accepting several subscribers
    • withCancellationAfterLastSubscriberDeparture

      @CheckReturnValue public MultiBroadcast<T> withCancellationAfterLastSubscriberDeparture()
      Indicates that the subscription to the upstream Multi is cancelled once all the subscribers have cancelled their subscription.
      Returns:
      this MultiBroadcast.
    • withCancellationAfterLastSubscriberDeparture

      @CheckReturnValue public MultiBroadcast<T> withCancellationAfterLastSubscriberDeparture(Duration delay)
      Indicates that the subscription to the upstream Multi is cancelled once all the subscribers have cancelled their subscription. Before cancelling it wait for a grace period of delay. If any subscriber subscribes during this period, the cancellation will not happen.
      Parameters:
      delay - the delay, must not be null, must be positive
      Returns:
      this MultiBroadcast.