Class AbstractMulti<T>

    • Constructor Detail

      • AbstractMulti

        public AbstractMulti()
    • Method Detail

      • subscribe

        public void subscribe​(org.reactivestreams.Subscriber<? super T> subscriber)
        Specified by:
        subscribe in interface org.reactivestreams.Publisher<T>
      • onItem

        public MultiOnItem<T> onItem()
        Description copied from interface: Multi
        Configures the behavior when an item event is received from the this Multi
        Specified by:
        onItem in interface Multi<T>
        Returns:
        the object to configure the behavior.
      • subscribe

        public MultiSubscribe<T> subscribe()
        Description copied from interface: Multi
        Configures the subscriber consuming this Multi.
        Specified by:
        subscribe in interface Multi<T>
        Returns:
        the object to configure the subscriber
      • toUni

        public Uni<T> toUni()
        Description copied from interface: Multi
        Creates a Uni 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:

        • on item event, the item is fired by the produced Uni
        • on failure event, the failure is fired by the produced Uni
        • on completion event, a null item is fired by the produces Uni
        • any item or failure events received after the first event is dropped

        If the subscription on the produced Uni is cancelled, the subscription to the passed Multi is also cancelled.

        Specified by:
        toUni in interface Multi<T>
        Returns:
        the produced Uni
      • onFailure

        public MultiOnFailure<T> onFailure()
        Description copied from interface: Multi
        Like Multi.onFailure(Predicate) but applied to all failures fired by the upstream multi. It allows configuring the on failure behavior (recovery, retry...).
        Specified by:
        onFailure in interface Multi<T>
        Returns:
        a MultiOnFailure on which you can specify the on failure action
      • onFailure

        public MultiOnFailure<T> onFailure​(java.util.function.Predicate<? super java.lang.Throwable> predicate)
        Description copied from interface: Multi
        Configures a predicate filtering the failures on which the behavior (specified with the returned MultiOnFailure) 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.

        Specified by:
        onFailure in interface Multi<T>
        Parameters:
        predicate - the predicate, null means applied to all failures
        Returns:
        a MultiOnFailure configured with the given predicate on which you can specify the on failure action
      • onFailure

        public MultiOnFailure<T> onFailure​(java.lang.Class<? extends java.lang.Throwable> typeOfFailure)
        Description copied from interface: Multi
        Configures a type of failure filtering the failures on which the behavior (specified with the returned MultiOnFailure) 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.*

        Specified by:
        onFailure in interface Multi<T>
        Parameters:
        typeOfFailure - the class of exception, must not be null
        Returns:
        a MultiOnFailure configured with the given predicate on which you can specify the on failure action
      • cache

        public Multi<T> cache()
        Description copied from interface: Multi
        Creates a new Multi that subscribes to this upstream and caches all of its events and replays them, to all the downstream subscribers.
        Specified by:
        cache in interface Multi<T>
        Returns:
        a multi replaying the events from the upstream.
      • emitOn

        public Multi<T> emitOn​(java.util.concurrent.Executor executor)
        Description copied from interface: Multi
        Produces a new Multi 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.

        Specified by:
        emitOn in interface Multi<T>
        Parameters:
        executor - the executor to use, must not be null
        Returns:
        a new Multi
      • runSubscriptionOn

        public Multi<T> runSubscriptionOn​(java.util.concurrent.Executor executor)
        Description copied from interface: Multi
        When a subscriber subscribes to this Multi, 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)
        Specified by:
        runSubscriptionOn in interface Multi<T>
        Parameters:
        executor - the executor to use, must not be null
        Returns:
        a new Multi
      • onCompletion

        public MultiOnCompletion<T> onCompletion()
        Description copied from interface: Multi
        Allows configuring the actions or continuation to execute when this Multi fires the completion event.
        Specified by:
        onCompletion in interface Multi<T>
        Returns:
        the object to configure the action.
      • transform

        public MultiTransform<T> transform()
        Description copied from interface: Multi
        Transforms the streams by skipping, selecting, or merging.
        Specified by:
        transform in interface Multi<T>
        Returns:
        the object to configure the transformation.
      • select

        public MultiSelect<T> select()
        Description copied from interface: Multi
        Selects items from this Multi.
        Specified by:
        select in interface Multi<T>
        Returns:
        the object to configure the selection.
      • skip

        public MultiSkip<T> skip()
        Description copied from interface: Multi
        Skips items from this Multi.
        Specified by:
        skip in interface Multi<T>
        Returns:
        the object to configure the skip.
      • onOverflow

        public MultiOverflow<T> onOverflow()
        Description copied from interface: Multi
        Configures the back-pressure behavior when the consumer cannot keep up with the emissions from this Multi.
        Specified by:
        onOverflow in interface Multi<T>
        Returns:
        the object to configure the overflow strategy
      • onSubscribe

        public MultiOnSubscribe<T> onSubscribe()
        Description copied from interface: Multi
        Configures the action to execute when the observed Multi 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().call(sub -> Uni.createFrom(1).onItem().delayIt().by(Duration.ofSecond(1)));
         
         
        Specified by:
        onSubscribe in interface Multi<T>
        Returns:
        the object to configure the action to execution on subscription.
      • onSubscription

        public MultiOnSubscribe<T> onSubscription()
        Description copied from interface: Multi
        Configures the action to execute when the observed Multi sends a Subscription. The downstream does not have a subscription yet. It will be passed once the configured action completes.

        For example:

         
         multi.onSubscription().invoke(sub -> System.out.println("subscribed"));
         // Delay the subscription by 1 second (or until an asynchronous action completes)
         multi.onSubscription().call(sub -> Uni.createFrom(1).onItem().delayIt().by(Duration.ofSecond(1)));
         
         
        Specified by:
        onSubscription in interface Multi<T>
        Returns:
        the object to configure the action to execution on subscription.
      • broadcast

        public MultiBroadcast<T> broadcast()
        Description copied from interface: Multi
        Makes this Multi be able to broadcast its events (items, failure, and completion) to multiple subscribers.
        Specified by:
        broadcast in interface Multi<T>
        Returns:
        the object to configure the broadcast
      • convert

        public MultiConvert<T> convert()
        Description copied from interface: Multi
        Converts a Multi to other types

        Examples:

         
         multi.convert().with(multi -> x); // Convert with a custom lambda converter
         
         
        Specified by:
        convert in interface Multi<T>
        Returns:
        the object to convert an Multi instance
        See Also:
        MultiConvert
      • onTermination

        public MultiOnTerminate<T> onTermination()
        Description copied from interface: Multi
        Configures actions when this Multi terminates on completion, on failure or on subscriber cancellation.
        Specified by:
        onTermination in interface Multi<T>
        Returns:
        the object to configure the termination actions
      • onCancellation

        public MultiOnCancel<T> onCancellation()
        Description copied from interface: Multi
        Configures actions when the subscriber cancels the subscription.
        Specified by:
        onCancellation in interface Multi<T>
        Returns:
        the object to configure the cancellation actions
      • onRequest

        public MultiOnRequest<T> onRequest()
        Description copied from interface: Multi
        Configures actions when items are being requested.
        Specified by:
        onRequest in interface Multi<T>
        Returns:
        the object to configure the actions
      • collect

        public MultiCollect<T> collect()
        Description copied from interface: Multi
        Produces Uni collecting/aggregating items from this Multi. It allows accumulating the items emitted by this multi into a structure such as a into a List (MultiCollect.asList()), a Map (MultiCollect.asMap(Function), or a custom collector. When this multi sends the completion signal, the structure is emitted by the returned Uni.

        If this Multi emits a failure, the produced Uni produces the same failure and the aggregated items are discarded.

        You can also retrieve the first and last items using MultiCollect.first() and MultiCollect.last(). Be aware to not used method collecting items on unbounded / infinite Multi.

        Specified by:
        collect in interface Multi<T>
        Returns:
        the object to configure the collection process.
      • toHotStream

        public Multi<T> toHotStream()
        Description copied from interface: Multi
        Produces a new Multi transforming this Multi into a hot stream. With a hot stream, when no subscribers are present, emitted items are dropped. Late subscribers would only receive items emitted after their subscription. If the upstream has already been terminated, the termination event (failure or completion) is forwarded to the subscribers. Note that this operator consumes the upstream stream without back-pressure. It still enforces downstream back-pressure. If the subscriber is not ready to receive an item when the upstream emits an item, the subscriber gets a BackPressureFailure failure.
        Specified by:
        toHotStream in interface Multi<T>
        Returns:
        the new multi.
      • log

        public Multi<T> log​(java.lang.String identifier)
        Description copied from interface: Multi
        Log events (onSubscribe, onItem, ...) as they come from the upstream or the subscriber. Events will be logged as long as the Multi hasn't been cancelled or terminated. Logging is framework-agnostic and can be configured in the Infrastructure class.
        Specified by:
        log in interface Multi<T>
        Parameters:
        identifier - an identifier of this operator to be used in log events
        Returns:
        a new Multi
        See Also:
        Infrastructure.setOperatorLogger(Infrastructure.OperatorLogger)