Class BroadcastProcessor<T>

  • All Implemented Interfaces:
    Multi<T>, org.reactivestreams.Processor<T,​T>, org.reactivestreams.Publisher<T>, org.reactivestreams.Subscriber<T>

    public class BroadcastProcessor<T>
    extends AbstractMulti<T>
    implements org.reactivestreams.Processor<T,​T>
    Implementation of Processor that broadcast all subsequently observed items to its current Subscribers.

    This processor does not coordinate back-pressure between different subscribers and between the upstream source and a subscriber. If an upstream item is received via onNext(Object), if a subscriber is not ready to receive that item, that subscriber is terminated via a BackPressureFailure.

    The BroadcastProcessor's Subscriber-side consumes items in an unbounded manner.

    When this BroadcastProcessor is terminated via onError(Throwable) or onComplete(), late Subscribers only receive the respective terminal event.

    Unlike the UnicastProcessor, a BroadcastProcessor doesn't retain/cache items, therefore, a new Subscriber won't receive any past items.

    Even though BroadcastProcessor implements the Subscriber interface, calling onSubscribe is not required if the processor is used as a standalone source. However, calling onSubscribe after the BroadcastProcessor has failed or reached completion results in the given Subscription being canceled immediately.

    • Method Detail

      • create

        public static <T> BroadcastProcessor<T> create()
        Creates a new BroadcastProcessor
        Type Parameters:
        T - the type of item
        Returns:
        the new BroadcastProcessor
      • onSubscribe

        public void onSubscribe​(org.reactivestreams.Subscription subscription)
        Specified by:
        onSubscribe in interface org.reactivestreams.Subscriber<T>
      • onNext

        public void onNext​(T item)
        Specified by:
        onNext in interface org.reactivestreams.Subscriber<T>
      • onError

        public void onError​(java.lang.Throwable failure)
        Specified by:
        onError in interface org.reactivestreams.Subscriber<T>
      • onComplete

        public void onComplete()
        Specified by:
        onComplete in interface org.reactivestreams.Subscriber<T>