Class MultiBroadcast<T>

  • Type Parameters:
    T - the type of item

    public class MultiBroadcast<T>
    extends java.lang.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 Detail

      • MultiBroadcast

        public MultiBroadcast​(Multi<T> upstream)
    • Method Detail

      • 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​(java.time.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.