Class MultiSubscribe<T>


  • public class MultiSubscribe<T>
    extends java.lang.Object
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      BlockingIterable<T> asIterable()  
      BlockingIterable<T> asIterable​(int batchSize, java.util.function.Supplier<java.util.Queue<T>> supplier)
      Consumes the upstream Multi as an iterable.
      BlockingIterable<T> asIterable​(java.util.function.Supplier<Context> contextSupplier)  
      BlockingIterable<T> asIterable​(java.util.function.Supplier<Context> contextSupplier, int batchSize, java.util.function.Supplier<java.util.Queue<T>> queueSupplier)
      Consumes the upstream Multi as an iterable.
      java.util.stream.Stream<T> asStream()  
      java.util.stream.Stream<T> asStream​(int batchSize, java.util.function.Supplier<java.util.Queue<T>> supplier)
      Consumes the items from the upstream Multi as a blocking stream.
      java.util.stream.Stream<T> asStream​(java.util.function.Supplier<Context> contextSupplier)  
      java.util.stream.Stream<T> asStream​(java.util.function.Supplier<Context> contextSupplier, int batchSize, java.util.function.Supplier<java.util.Queue<T>> queueSupplier)
      Consumes the items from the upstream Multi as a blocking stream.
      Cancellable with​(Context context, java.util.function.Consumer<? super org.reactivestreams.Subscription> onSubscription, java.util.function.Consumer<? super T> onItem, java.util.function.Consumer<? super java.lang.Throwable> onFailure, java.lang.Runnable onComplete)
      Subscribes to the Multi to start receiving the items.
      Cancellable with​(Context context, java.util.function.Consumer<? super T> onItem)
      Subscribes to the Multi to start receiving the items.
      Cancellable with​(Context context, java.util.function.Consumer<? super T> onItem, java.lang.Runnable onComplete)
      Subscribes to the Multi to start receiving the items.
      Cancellable with​(Context context, java.util.function.Consumer<? super T> onItem, java.util.function.Consumer<? super java.lang.Throwable> onFailure)
      Subscribes to the Multi to start receiving the items.
      Cancellable with​(Context context, java.util.function.Consumer<? super T> onItem, java.util.function.Consumer<? super java.lang.Throwable> onFailure, java.lang.Runnable onComplete)
      Subscribes to the Multi to start receiving the items.
      Cancellable with​(java.util.function.Consumer<? super org.reactivestreams.Subscription> onSubscription, java.util.function.Consumer<? super T> onItem, java.util.function.Consumer<? super java.lang.Throwable> onFailure, java.lang.Runnable onComplete)
      Subscribes to the Multi to start receiving the items.
      Cancellable with​(java.util.function.Consumer<? super T> onItem)
      Subscribes to the Multi to start receiving the items.
      Cancellable with​(java.util.function.Consumer<? super T> onItem, java.lang.Runnable onComplete)
      Subscribes to the Multi to start receiving the items.
      Cancellable with​(java.util.function.Consumer<? super T> onItem, java.util.function.Consumer<? super java.lang.Throwable> onFailure)
      Subscribes to the Multi to start receiving the items.
      Cancellable with​(java.util.function.Consumer<? super T> onItem, java.util.function.Consumer<? super java.lang.Throwable> onFailure, java.lang.Runnable onComplete)
      Subscribes to the Multi to start receiving the items.
      <S extends org.reactivestreams.Subscriber<? super T>>
      S
      withSubscriber​(S subscriber)
      Subscribes to the Multi to get a subscription and then start receiving items ( based on the passed requests).
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • MultiSubscribe

        public MultiSubscribe​(AbstractMulti<T> upstream)
    • Method Detail

      • withSubscriber

        public <S extends org.reactivestreams.Subscriber<? super T>> S withSubscriber​(S subscriber)
        Subscribes to the Multi to get a subscription and then start receiving items ( based on the passed requests).

        This is a "factory method" and can be called multiple times, each time starting a new Subscription. Each Subscription will work for only a single Subscriber. A Subscriber should only subscribe once to a single Multi.

        If the Multi rejects the subscription attempt or otherwise fails it will fire a failure event receiving by Subscriber.onError(Throwable).

        Type Parameters:
        S - the subscriber type
        Parameters:
        subscriber - the subscriber, must not be null
        Returns:
        the passed subscriber
      • withSubscriber

        public <S extends MultiSubscriber<? super T>> S withSubscriber​(S subscriber)
        Subscribes to the Multi to get a subscription and then start receiving items ( based on the passed requests).

        This is a "factory method" and can be called multiple times, each time starting a new Subscription. Each Subscription will work for only a single MultiSubscriber. A MultiSubscriber should only subscribe once to a single Multi.

        If the Multi rejects the subscription attempt or otherwise fails it will fire a failure event receiving by MultiSubscriber.onFailure(Throwable).

        Type Parameters:
        S - the subscriber type
        Parameters:
        subscriber - the subscriber, must not be null
        Returns:
        the passed subscriber
      • with

        public Cancellable with​(java.util.function.Consumer<? super org.reactivestreams.Subscription> onSubscription,
                                java.util.function.Consumer<? super T> onItem,
                                java.util.function.Consumer<? super java.lang.Throwable> onFailure,
                                java.lang.Runnable onComplete)
        Subscribes to the Multi to start receiving the items.

        This method accepts the following callbacks:

        1. onSubscription receives the Subscription, you must request items using the Subscription.request(long) method
        2. onItem receives the requested items if any
        3. onFailure receives the failure if any
        4. onComplete receives the completion event

        This method returns a Cancellable to cancel the subscription.

        This is a "factory method" and can be called multiple times, each time starting a new Subscription. Each Subscription will work for only a single Subscriber. A Subscriber should only subscribe once to a single Multi.

        Parameters:
        onSubscription - the callback receiving the subscription, must not be null
        onItem - the callback receiving the items, must not be null
        onFailure - the callback receiving the failure, must not be null
        onComplete - the callback receiving the completion event, must not be null
        Returns:
        the cancellable object to cancel the subscription
      • with

        @Experimental("Context support is a new experimental API introduced in Mutiny 1.3.0")
        public Cancellable with​(Context context,
                                java.util.function.Consumer<? super org.reactivestreams.Subscription> onSubscription,
                                java.util.function.Consumer<? super T> onItem,
                                java.util.function.Consumer<? super java.lang.Throwable> onFailure,
                                java.lang.Runnable onComplete)
        Subscribes to the Multi to start receiving the items.

        This method accepts the following callbacks:

        1. onSubscription receives the Subscription, you must request items using the Subscription.request(long) method
        2. onItem receives the requested items if any
        3. onFailure receives the failure if any
        4. onComplete receives the completion event

        This method returns a Cancellable to cancel the subscription.

        This is a "factory method" and can be called multiple times, each time starting a new Subscription. Each Subscription will work for only a single Subscriber. A Subscriber should only subscribe once to a single Multi.

        Parameters:
        context - the context, must not be null
        onSubscription - the callback receiving the subscription, must not be null
        onItem - the callback receiving the items, must not be null
        onFailure - the callback receiving the failure, must not be null
        onComplete - the callback receiving the completion event, must not be null
        Returns:
        the cancellable object to cancel the subscription
      • with

        public Cancellable with​(java.util.function.Consumer<? super T> onItem,
                                java.util.function.Consumer<? super java.lang.Throwable> onFailure,
                                java.lang.Runnable onComplete)
        Subscribes to the Multi to start receiving the items.

        This method accepts the following callbacks:

        1. onItem receives the requested items if any
        2. onFailure receives the failure if any
        3. onComplete receives the completion event

        This method returns a Cancellable to cancel the subscription. Important: This method request Long.MAX_VALUE items.

        This is a "factory method" and can be called multiple times, each time starting a new Subscription. Each Subscription will work for only a single Subscriber. A Subscriber should only subscribe once to a single Multi.

        Parameters:
        onItem - the callback receiving the items, must not be null
        onFailure - the callback receiving the failure, must not be null
        onComplete - the callback receiving the completion event, must not be null
        Returns:
        the cancellable object to cancel the subscription
      • with

        @Experimental("Context support is a new experimental API introduced in Mutiny 1.3.0")
        public Cancellable with​(Context context,
                                java.util.function.Consumer<? super T> onItem,
                                java.util.function.Consumer<? super java.lang.Throwable> onFailure,
                                java.lang.Runnable onComplete)
        Subscribes to the Multi to start receiving the items.

        This method accepts the following callbacks:

        1. onItem receives the requested items if any
        2. onFailure receives the failure if any
        3. onComplete receives the completion event

        This method returns a Cancellable to cancel the subscription. Important: This method request Long.MAX_VALUE items.

        This is a "factory method" and can be called multiple times, each time starting a new Subscription. Each Subscription will work for only a single Subscriber. A Subscriber should only subscribe once to a single Multi.

        Parameters:
        context - the context, must not be null
        onItem - the callback receiving the items, must not be null
        onFailure - the callback receiving the failure, must not be null
        onComplete - the callback receiving the completion event, must not be null
        Returns:
        the cancellable object to cancel the subscription
      • with

        public Cancellable with​(java.util.function.Consumer<? super T> onItem,
                                java.util.function.Consumer<? super java.lang.Throwable> onFailure)
        Subscribes to the Multi to start receiving the items.

        This method accepts the following callbacks:

        1. onItem receives the requested items if any
        2. onFailure receives the failure if any

        So, you won't be notified on stream completion.

        This method returns a Cancellable to cancel the subscription. Important: This method request Long.MAX_VALUE items.

        This is a "factory method" and can be called multiple times, each time starting a new Subscription. Each Subscription will work for only a single Subscriber. A Subscriber should only subscribe once to a single Multi. *

        Parameters:
        onItem - the callback receiving the items, must not be null
        onFailure - the callback receiving the failure, must not be null
        Returns:
        the cancellable object to cancel the subscription
      • with

        @Experimental("Context support is a new experimental API introduced in Mutiny 1.3.0")
        public Cancellable with​(Context context,
                                java.util.function.Consumer<? super T> onItem,
                                java.util.function.Consumer<? super java.lang.Throwable> onFailure)
        Subscribes to the Multi to start receiving the items.

        This method accepts the following callbacks:

        1. onItem receives the requested items if any
        2. onFailure receives the failure if any

        So, you won't be notified on stream completion.

        This method returns a Cancellable to cancel the subscription. Important: This method request Long.MAX_VALUE items.

        This is a "factory method" and can be called multiple times, each time starting a new Subscription. Each Subscription will work for only a single Subscriber. A Subscriber should only subscribe once to a single Multi. *

        Parameters:
        context - the context, must not be null
        onItem - the callback receiving the items, must not be null
        onFailure - the callback receiving the failure, must not be null
        Returns:
        the cancellable object to cancel the subscription
      • with

        public Cancellable with​(java.util.function.Consumer<? super T> onItem)
        Subscribes to the Multi to start receiving the items.

        This method receives only the onItem callback, invoked on each item. So, you won't be notified on stream completion, and on failure the default failure handler is used.

        This method returns a Cancellable to cancel the subscription. Important: This method request Long.MAX_VALUE items.

        This is a "factory method" and can be called multiple times, each time starting a new Subscription. Each Subscription will work for only a single Subscriber. A Subscriber should only subscribe once to a single Multi. *

        Parameters:
        onItem - the callback receiving the items, must not be null
        Returns:
        the cancellable object to cancel the subscription
      • with

        @Experimental("Context support is a new experimental API introduced in Mutiny 1.3.0")
        public Cancellable with​(Context context,
                                java.util.function.Consumer<? super T> onItem)
        Subscribes to the Multi to start receiving the items.

        This method receives only the onItem callback, invoked on each item. So, you won't be notified on stream completion, and on failure the default failure handler is used.

        This method returns a Cancellable to cancel the subscription. Important: This method request Long.MAX_VALUE items.

        This is a "factory method" and can be called multiple times, each time starting a new Subscription. Each Subscription will work for only a single Subscriber. A Subscriber should only subscribe once to a single Multi. *

        Parameters:
        context - the context, must not be null
        onItem - the callback receiving the items, must not be null
        Returns:
        the cancellable object to cancel the subscription
      • with

        public Cancellable with​(java.util.function.Consumer<? super T> onItem,
                                java.lang.Runnable onComplete)
        Subscribes to the Multi to start receiving the items.

        This method accepts the following callbacks:

        1. onItem receives the requested items if any
        2. onComplete receives the completion event

        So, you won't be notified on failure.

        This method returns a Cancellable to cancel the subscription. Important: This method request Long.MAX_VALUE items.

        This is a "factory method" and can be called multiple times, each time starting a new Subscription. Each Subscription will work for only a single Subscriber. A Subscriber should only subscribe once to a single Multi.

        Parameters:
        onItem - the callback receiving the items, must not be null
        onComplete - the callback receiving the completion event, must not be null
        Returns:
        the cancellable object to cancel the subscription
      • with

        @Experimental("Context support is a new experimental API introduced in Mutiny 1.3.0")
        public Cancellable with​(Context context,
                                java.util.function.Consumer<? super T> onItem,
                                java.lang.Runnable onComplete)
        Subscribes to the Multi to start receiving the items.

        This method accepts the following callbacks:

        1. onItem receives the requested items if any
        2. onComplete receives the completion event

        So, you won't be notified on failure.

        This method returns a Cancellable to cancel the subscription. Important: This method request Long.MAX_VALUE items.

        This is a "factory method" and can be called multiple times, each time starting a new Subscription. Each Subscription will work for only a single Subscriber. A Subscriber should only subscribe once to a single Multi.

        Parameters:
        context - the context, must not be null
        onItem - the callback receiving the items, must not be null
        onComplete - the callback receiving the completion event, must not be null
        Returns:
        the cancellable object to cancel the subscription
      • asIterable

        @CheckReturnValue
        public BlockingIterable<T> asIterable()
        Returns:
        a blocking iterable used to consume the items emitted by the upstream Multi.
      • asIterable

        @CheckReturnValue
        @Experimental("Context support is a new experimental API introduced in Mutiny 1.3.0")
        public BlockingIterable<T> asIterable​(java.util.function.Supplier<Context> contextSupplier)
        Parameters:
        contextSupplier - the context supplier, must not be null, must not return null
        Returns:
        a blocking iterable used to consume the items emitted by the upstream Multi.
      • asIterable

        @CheckReturnValue
        public BlockingIterable<T> asIterable​(int batchSize,
                                              java.util.function.Supplier<java.util.Queue<T>> supplier)
        Consumes the upstream Multi as an iterable.
        Parameters:
        batchSize - the number of elements stored in the queue
        supplier - the supplier of queue used internally, must not be null, must not return null
        Returns:
        a blocking iterable used to consume the items emitted by the upstream Multi.
      • asIterable

        @CheckReturnValue
        @Experimental("Context support is a new experimental API introduced in Mutiny 1.3.0")
        public BlockingIterable<T> asIterable​(java.util.function.Supplier<Context> contextSupplier,
                                              int batchSize,
                                              java.util.function.Supplier<java.util.Queue<T>> queueSupplier)
        Consumes the upstream Multi as an iterable.
        Parameters:
        contextSupplier - the context supplier, must not be null, must not return null
        batchSize - the number of elements stored in the queue
        queueSupplier - the supplier of queue used internally, must not be null, must not return null
        Returns:
        a blocking iterable used to consume the items emitted by the upstream Multi.
      • asStream

        @CheckReturnValue
        public java.util.stream.Stream<T> asStream()
        Returns:
        a blocking stream to consume the items from the upstream Multi.
      • asStream

        @CheckReturnValue
        @Experimental("Context support is a new experimental API introduced in Mutiny 1.3.0")
        public java.util.stream.Stream<T> asStream​(java.util.function.Supplier<Context> contextSupplier)
        Parameters:
        contextSupplier - the context supplier, must not be null, must not return null
        Returns:
        a blocking stream to consume the items from the upstream Multi.
      • asStream

        @CheckReturnValue
        public java.util.stream.Stream<T> asStream​(int batchSize,
                                                   java.util.function.Supplier<java.util.Queue<T>> supplier)
        Consumes the items from the upstream Multi as a blocking stream.
        Parameters:
        batchSize - the number of element stored in the queue
        supplier - the supplier of queue used internally, must not be null, must not return null
        Returns:
        a blocking stream used to consume the items from Multi
      • asStream

        @CheckReturnValue
        @Experimental("Context support is a new experimental API introduced in Mutiny 1.3.0")
        public java.util.stream.Stream<T> asStream​(java.util.function.Supplier<Context> contextSupplier,
                                                   int batchSize,
                                                   java.util.function.Supplier<java.util.Queue<T>> queueSupplier)
        Consumes the items from the upstream Multi as a blocking stream.
        Parameters:
        contextSupplier - the context supplier, must not be null, must not return null
        batchSize - the number of element stored in the queue
        queueSupplier - the supplier of queue used internally, must not be null, must not return null
        Returns:
        a blocking stream used to consume the items from Multi