public abstract class AbstractMulti<T> extends Object implements Multi<T>
| Constructor and Description |
|---|
AbstractMulti() |
| Modifier and Type | Method and Description |
|---|---|
MultiBroadcast<T> |
broadcast()
Makes this
Multi be able to broadcast its events (items, failure, and completion)
to multiple subscribers. |
Multi<T> |
cache()
Creates a new
Multi that subscribes to this upstream and caches all of its events and replays them, to
all the downstream subscribers. |
MultiCollect<T> |
collectItems()
|
MultiConvert<T> |
convert()
Converts a
Multi to other types |
Multi<T> |
emitOn(Executor executor)
|
MultiGroup<T> |
groupItems()
|
MultiOnEvent<T> |
on()
Allows adding behavior when various type of events are emitted by the current
Multi (item, failure,
completion) or by the subscriber (cancellation, request, subscription) |
MultiOnCompletion<T> |
onCompletion()
Allows configuring the actions or continuation to execute when this
Multi fires the completion event. |
MultiOnFailure<T> |
onFailure()
Like
Multi.onFailure(Predicate) but applied to all failures fired by the upstream multi. |
MultiOnFailure<T> |
onFailure(Class<? extends Throwable> typeOfFailure)
Configures a type of failure filtering the failures on which the behavior (specified with the returned
MultiOnFailure) is applied. |
MultiOnFailure<T> |
onFailure(Predicate<? super Throwable> predicate)
Configures a predicate filtering the failures on which the behavior (specified with the returned
MultiOnFailure) is applied. |
MultiOnItem<T> |
onItem()
Configures the behavior when an
item event is received from the this Multi |
MultiOverflow<T> |
onOverflow()
Configures the back-pressure behavior when the consumer cannot keep up with the emissions from this
Multi. |
MultiOnSubscribe<T> |
onSubscribe()
Configures the action to execute when the observed
Multi sends a Subscription. |
MultiOnTerminate<T> |
onTermination()
Configures actions when this
Multi terminates on completion, on failure or on subscriber cancellation. |
Multi<T> |
runSubscriptionOn(Executor executor)
|
MultiSubscribe<T> |
subscribe()
Configures the subscriber consuming this
Multi. |
void |
subscribe(MultiSubscriber<? super T> subscriber) |
void |
subscribe(org.reactivestreams.Subscriber<? super T> subscriber) |
Uni<T> |
toUni()
|
MultiTransform<T> |
transform()
Transforms the streams by skipping, selecting, or merging.
|
public void subscribe(MultiSubscriber<? super T> subscriber)
public void subscribe(org.reactivestreams.Subscriber<? super T> subscriber)
subscribe in interface org.reactivestreams.Publisher<T>public MultiOnItem<T> onItem()
Multiitem event is received from the this Multipublic MultiSubscribe<T> subscribe()
MultiMulti.public Uni<T> toUni()
MultiUni from this Multi.
When a subscriber subscribes to the returned Uni, it subscribes to this Multi and requests one
item. The event emitted by this Multi are then forwarded to the Uni:
UniUninull item is fired by the produces Uni
If the subscription on the produced Uni is cancelled, the subscription to the passed Multi is
also cancelled.
public MultiOnFailure<T> onFailure()
MultiMulti.onFailure(Predicate) but applied to all failures fired by the upstream multi.
It allows configuring the on failure behavior (recovery, retry...).public MultiOnFailure<T> onFailure(Predicate<? super Throwable> predicate)
MultiMultiOnFailure) is applied.
For instance, to only when an IOException is fired as failure you can use:
multi.onFailure(IOException.class).recoverWithItem("hello")
The fallback value (hello) will only be used if the upstream multi fires a failure of type
IOException.
public MultiOnFailure<T> onFailure(Class<? extends Throwable> typeOfFailure)
MultiMultiOnFailure) is applied.
For instance, to only when an IOException is fired as failure you can use:
multi.onFailure(IOException.class).recoverWithItem("hello")
The fallback value (hello) will only be used if the upstream multi fire a failure of type
IOException.*
public MultiOnEvent<T> on()
MultiMulti (item, failure,
completion) or by the subscriber (cancellation, request, subscription)public Multi<T> cache()
MultiMulti that subscribes to this upstream and caches all of its events and replays them, to
all the downstream subscribers.public MultiCollect<T> collectItems()
MultiMulti or Uni collecting items from this Multi. You can accumulate the items
into a List (MultiCollect.asList()), Map
(MultiCollect.asMap(Function)...
You can also retrieve the first and list items using MultiCollect.first() and MultiCollect.last().
collectItems in interface Multi<T>public MultiGroup<T> groupItems()
MultiMulti grouping items from this Multi into various "form of chunks" (list, Multi).
The grouping can be done linearly (MultiGroup.intoLists() and MultiGroup.intoMultis(), or based
on a grouping function (MultiGroup.by(Function))groupItems in interface Multi<T>public Multi<T> emitOn(Executor executor)
MultiMulti invoking the onItem, onFailure and onCompletion methods
on the supplied Executor.
Instead of receiving the item event on the thread firing the event, this method influences the
threading context to switch to a thread from the given executor. Same behavior for failure and completion.
Note that the subscriber is guaranteed to never be called concurrently.
public Multi<T> runSubscriptionOn(Executor executor)
MultiMulti, execute the subscription to the upstream Multi on a
thread from the given executor. As a result, the Subscriber.onSubscribe(Subscription) method will be called
on this thread (except mentioned otherwise)runSubscriptionOn in interface Multi<T>executor - the executor to use, must not be nullMultipublic MultiOnCompletion<T> onCompletion()
MultiMulti fires the completion event.onCompletion in interface Multi<T>public MultiTransform<T> transform()
Multipublic MultiOverflow<T> onOverflow()
MultiMulti.onOverflow in interface Multi<T>public MultiOnSubscribe<T> onSubscribe()
MultiMulti sends a Subscription.
The downstream don't have a subscription yet. It will be passed once the configured action completes.
For example:
multi.onSubscribe().invoke(sub -> System.out.println("subscribed"));
// Delay the subscription by 1 second (or until an asynchronous action completes)
multi.onSubscribe().invokeUni(sub -> Uni.createFrom(1).onItem().delayIt().by(Duration.ofSecond(1)));
onSubscribe in interface Multi<T>public MultiBroadcast<T> broadcast()
MultiMulti be able to broadcast its events (items, failure, and completion)
to multiple subscribers.public MultiConvert<T> convert()
MultiMulti to other types
Examples:
multi.convert().with(multi -> x); // Convert with a custom lambda converter
convert in interface Multi<T>Multi instanceMultiConvertpublic MultiOnTerminate<T> onTermination()
MultiMulti terminates on completion, on failure or on subscriber cancellation.onTermination in interface Multi<T>Copyright © 2019–2020 SmallRye. All rights reserved.