Class BlockingBackpressureOperator<T>

  • Type Parameters:
    T - Type of data processed by the Flowable
    All Implemented Interfaces:
    FlowableOperator<T,​T>

    public final class BlockingBackpressureOperator<T>
    extends Object
    implements FlowableOperator<T,​T>
    Allows to connect a non back-pressure aware Publisher into a reactive stream. This is needed to interface callback-based legacy code with back-pressure aware reactive-code.

    To prevent overflow when a non back-pressure aware publisher emits items which have not requested by the subscriber, the wrapped Subscriber will be blocked before propagating the onNext() invocation. To do so, each Subscriber is wrapped into a BlockingBackpressureOperator.BlockingSubscriberWrapper which will block the onNext() caller until the Subscriber is ready to receive the item (Subscription.request(long)).

    • Constructor Detail

      • BlockingBackpressureOperator

        public BlockingBackpressureOperator​(Duration timeout,
                                            Supplier<Exception> timeoutExceptionSupplier)
        Creates a new operator allowing to plug non back-pressure aware Publisher to a Flowable chain. The transformer will block the emitter thread waiting until whether the receiver is ready to process the item or the provided time-out expires in which case TimeoutException will be propagated through onError().
        Parameters:
        timeout - Duration this transformer will wait for the receiver to be ready.
        timeoutExceptionSupplier - supplier that will generate the exception to signal a timeout
    • Method Detail

      • apply

        public org.reactivestreams.Subscriber<? super T> apply​(org.reactivestreams.Subscriber<? super T> subscriber)
        Specified by:
        apply in interface FlowableOperator<T,​T>