Class MultiSubscribe<T>

java.lang.Object
io.smallrye.mutiny.groups.MultiSubscribe<T>

public class MultiSubscribe<T> extends Object
  • Constructor Details

  • Method Details

    • withSubscriber

      public <S extends Flow.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 Flow.Subscription. Each Flow.Subscription will work for only a single Flow.Subscriber. A Flow.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 Flow.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 Flow.Subscription. Each Flow.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(Consumer<? super Flow.Subscription> onSubscription, Consumer<? super T> onItem, Consumer<? super Throwable> onFailure, Runnable onComplete)
      Subscribes to the Multi to start receiving the items.

      This method accepts the following callbacks:

      1. onSubscription receives the Flow.Subscription, you must request items using the Flow.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 Flow.Subscription. Each Flow.Subscription will work for only a single Flow.Subscriber. A Flow.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

      public Cancellable with(Context context, Consumer<? super Flow.Subscription> onSubscription, Consumer<? super T> onItem, Consumer<? super Throwable> onFailure, Runnable onComplete)
      Subscribes to the Multi to start receiving the items.

      This method accepts the following callbacks:

      1. onSubscription receives the Flow.Subscription, you must request items using the Flow.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 Flow.Subscription. Each Flow.Subscription will work for only a single Flow.Subscriber. A Flow.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(Consumer<? super T> onItem, Consumer<? super Throwable> onFailure, 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 Flow.Subscription. Each Flow.Subscription will work for only a single Flow.Subscriber. A Flow.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

      public Cancellable with(Context context, Consumer<? super T> onItem, Consumer<? super Throwable> onFailure, 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 Flow.Subscription. Each Flow.Subscription will work for only a single Flow.Subscriber. A Flow.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(Consumer<? super T> onItem, Consumer<? super 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 Flow.Subscription. Each Flow.Subscription will work for only a single Flow.Subscriber. A Flow.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

      public Cancellable with(Context context, Consumer<? super T> onItem, Consumer<? super 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 Flow.Subscription. Each Flow.Subscription will work for only a single Flow.Subscriber. A Flow.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(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 Flow.Subscription. Each Flow.Subscription will work for only a single Flow.Subscriber. A Flow.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

      public Cancellable with(Context context, 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 Flow.Subscription. Each Flow.Subscription will work for only a single Flow.Subscriber. A Flow.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(Consumer<? super T> onItem, 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 Flow.Subscription. Each Flow.Subscription will work for only a single Flow.Subscriber. A Flow.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

      public Cancellable with(Context context, Consumer<? super T> onItem, 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 Flow.Subscription. Each Flow.Subscription will work for only a single Flow.Subscriber. A Flow.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 io.smallrye.mutiny.helpers.BlockingIterable<T> asIterable()
      Returns:
      a blocking iterable used to consume the items emitted by the upstream Multi.
    • asIterable

      @CheckReturnValue public io.smallrye.mutiny.helpers.BlockingIterable<T> asIterable(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 io.smallrye.mutiny.helpers.BlockingIterable<T> asIterable(int batchSize, Supplier<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 public io.smallrye.mutiny.helpers.BlockingIterable<T> asIterable(Supplier<Context> contextSupplier, int batchSize, Supplier<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 Stream<T> asStream()
      Returns:
      a blocking stream to consume the items from the upstream Multi.
    • asStream

      @CheckReturnValue public Stream<T> asStream(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 Stream<T> asStream(int batchSize, Supplier<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 public Stream<T> asStream(Supplier<Context> contextSupplier, int batchSize, Supplier<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