Class MultiSubscribe<T>
- java.lang.Object
-
- io.smallrye.mutiny.groups.MultiSubscribe<T>
-
public class MultiSubscribe<T> extends java.lang.Object
-
-
Constructor Summary
Constructors Constructor Description MultiSubscribe(AbstractMulti<T> upstream)
-
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 upstreamMulti
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 upstreamMulti
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 upstreamMulti
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 upstreamMulti
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 theMulti
to start receiving the items.Cancellable
with(Context context, java.util.function.Consumer<? super T> onItem)
Subscribes to theMulti
to start receiving the items.Cancellable
with(Context context, java.util.function.Consumer<? super T> onItem, java.lang.Runnable onComplete)
Subscribes to theMulti
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 theMulti
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 theMulti
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 theMulti
to start receiving the items.Cancellable
with(java.util.function.Consumer<? super T> onItem)
Subscribes to theMulti
to start receiving the items.Cancellable
with(java.util.function.Consumer<? super T> onItem, java.lang.Runnable onComplete)
Subscribes to theMulti
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 theMulti
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 theMulti
to start receiving the items.<S extends org.reactivestreams.Subscriber<? super T>>
SwithSubscriber(S subscriber)
Subscribes to theMulti
to get a subscription and then start receiving items ( based on the passed requests).
-
-
-
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 theMulti
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
. EachSubscription
will work for only a singleSubscriber
. ASubscriber
should only subscribe once to a singleMulti
.If the
Multi
rejects the subscription attempt or otherwise fails it will fire afailure
event receiving bySubscriber.onError(Throwable)
.- Type Parameters:
S
- the subscriber type- Parameters:
subscriber
- the subscriber, must not benull
- Returns:
- the passed subscriber
-
withSubscriber
public <S extends MultiSubscriber<? super T>> S withSubscriber(S subscriber)
Subscribes to theMulti
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
. EachSubscription
will work for only a singleMultiSubscriber
. AMultiSubscriber
should only subscribe once to a singleMulti
.If the
Multi
rejects the subscription attempt or otherwise fails it will fire afailure
event receiving byMultiSubscriber.onFailure(Throwable)
.- Type Parameters:
S
- the subscriber type- Parameters:
subscriber
- the subscriber, must not benull
- 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 theMulti
to start receiving the items.This method accepts the following callbacks:
onSubscription
receives theSubscription
, you must request items using theSubscription.request(long)
methodonItem
receives the requested items if anyonFailure
receives the failure if anyonComplete
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
. EachSubscription
will work for only a singleSubscriber
. ASubscriber
should only subscribe once to a singleMulti
.- Parameters:
onSubscription
- the callback receiving the subscription, must not benull
onItem
- the callback receiving the items, must not benull
onFailure
- the callback receiving the failure, must not benull
onComplete
- the callback receiving the completion event, must not benull
- 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 theMulti
to start receiving the items.This method accepts the following callbacks:
onSubscription
receives theSubscription
, you must request items using theSubscription.request(long)
methodonItem
receives the requested items if anyonFailure
receives the failure if anyonComplete
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
. EachSubscription
will work for only a singleSubscriber
. ASubscriber
should only subscribe once to a singleMulti
.- Parameters:
context
- the context, must not benull
onSubscription
- the callback receiving the subscription, must not benull
onItem
- the callback receiving the items, must not benull
onFailure
- the callback receiving the failure, must not benull
onComplete
- the callback receiving the completion event, must not benull
- 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 theMulti
to start receiving the items.This method accepts the following callbacks:
onItem
receives the requested items if anyonFailure
receives the failure if anyonComplete
receives the completion event
This method returns a
Cancellable
to cancel the subscription. Important: This method requestLong.MAX_VALUE
items.This is a "factory method" and can be called multiple times, each time starting a new
Subscription
. EachSubscription
will work for only a singleSubscriber
. ASubscriber
should only subscribe once to a singleMulti
.- Parameters:
onItem
- the callback receiving the items, must not benull
onFailure
- the callback receiving the failure, must not benull
onComplete
- the callback receiving the completion event, must not benull
- 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 theMulti
to start receiving the items.This method accepts the following callbacks:
onItem
receives the requested items if anyonFailure
receives the failure if anyonComplete
receives the completion event
This method returns a
Cancellable
to cancel the subscription. Important: This method requestLong.MAX_VALUE
items.This is a "factory method" and can be called multiple times, each time starting a new
Subscription
. EachSubscription
will work for only a singleSubscriber
. ASubscriber
should only subscribe once to a singleMulti
.- Parameters:
context
- the context, must not benull
onItem
- the callback receiving the items, must not benull
onFailure
- the callback receiving the failure, must not benull
onComplete
- the callback receiving the completion event, must not benull
- 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 theMulti
to start receiving the items.This method accepts the following callbacks:
onItem
receives the requested items if anyonFailure
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 requestLong.MAX_VALUE
items.This is a "factory method" and can be called multiple times, each time starting a new
Subscription
. EachSubscription
will work for only a singleSubscriber
. ASubscriber
should only subscribe once to a singleMulti
. *- Parameters:
onItem
- the callback receiving the items, must not benull
onFailure
- the callback receiving the failure, must not benull
- 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 theMulti
to start receiving the items.This method accepts the following callbacks:
onItem
receives the requested items if anyonFailure
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 requestLong.MAX_VALUE
items.This is a "factory method" and can be called multiple times, each time starting a new
Subscription
. EachSubscription
will work for only a singleSubscriber
. ASubscriber
should only subscribe once to a singleMulti
. *- Parameters:
context
- the context, must not benull
onItem
- the callback receiving the items, must not benull
onFailure
- the callback receiving the failure, must not benull
- Returns:
- the cancellable object to cancel the subscription
-
with
public Cancellable with(java.util.function.Consumer<? super T> onItem)
Subscribes to theMulti
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 requestLong.MAX_VALUE
items.This is a "factory method" and can be called multiple times, each time starting a new
Subscription
. EachSubscription
will work for only a singleSubscriber
. ASubscriber
should only subscribe once to a singleMulti
. *- Parameters:
onItem
- the callback receiving the items, must not benull
- 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 theMulti
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 requestLong.MAX_VALUE
items.This is a "factory method" and can be called multiple times, each time starting a new
Subscription
. EachSubscription
will work for only a singleSubscriber
. ASubscriber
should only subscribe once to a singleMulti
. *- Parameters:
context
- the context, must not benull
onItem
- the callback receiving the items, must not benull
- 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 theMulti
to start receiving the items.This method accepts the following callbacks:
onItem
receives the requested items if anyonComplete
receives the completion event
So, you won't be notified on failure.
This method returns a
Cancellable
to cancel the subscription. Important: This method requestLong.MAX_VALUE
items.This is a "factory method" and can be called multiple times, each time starting a new
Subscription
. EachSubscription
will work for only a singleSubscriber
. ASubscriber
should only subscribe once to a singleMulti
.- Parameters:
onItem
- the callback receiving the items, must not benull
onComplete
- the callback receiving the completion event, must not benull
- 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 theMulti
to start receiving the items.This method accepts the following callbacks:
onItem
receives the requested items if anyonComplete
receives the completion event
So, you won't be notified on failure.
This method returns a
Cancellable
to cancel the subscription. Important: This method requestLong.MAX_VALUE
items.This is a "factory method" and can be called multiple times, each time starting a new
Subscription
. EachSubscription
will work for only a singleSubscriber
. ASubscriber
should only subscribe once to a singleMulti
.- Parameters:
context
- the context, must not benull
onItem
- the callback receiving the items, must not benull
onComplete
- the callback receiving the completion event, must not benull
- 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 benull
, must not returnnull
- 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 upstreamMulti
as an iterable.- Parameters:
batchSize
- the number of elements stored in the queuesupplier
- the supplier of queue used internally, must not benull
, must not returnnull
- 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 upstreamMulti
as an iterable.- Parameters:
contextSupplier
- the context supplier, must not benull
, must not returnnull
batchSize
- the number of elements stored in the queuequeueSupplier
- the supplier of queue used internally, must not benull
, must not returnnull
- 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 benull
, must not returnnull
- 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 upstreamMulti
as a blocking stream.- Parameters:
batchSize
- the number of element stored in the queuesupplier
- the supplier of queue used internally, must not benull
, must not returnnull
- 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 upstreamMulti
as a blocking stream.- Parameters:
contextSupplier
- the context supplier, must not benull
, must not returnnull
batchSize
- the number of element stored in the queuequeueSupplier
- the supplier of queue used internally, must not benull
, must not returnnull
- Returns:
- a blocking stream used to consume the items from
Multi
-
-