Class MultiMerge


  • public class MultiMerge
    extends java.lang.Object
    Creates new Multi by merging several Multi or Publisher.

    This class allows configuring how the merge is executed. Unlike a concatenation, a merge emits the items as they come, so the items may be interleaved.

    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      MultiMerge collectFailures()
      Indicates that the merge process should not propagate the first received failure, but collect them until all the items from all (non-failing) participants have been emitted.
      <T> Multi<T> streams​(java.lang.Iterable<? extends org.reactivestreams.Publisher<T>> iterable)
      Creates a new Multi merging the items emitted by the given publishers / publishers.
      <T> Multi<T> streams​(org.reactivestreams.Publisher<T>... publishers)
      Creates a new Multi merging the items emitted by the given multis / publishers.
      MultiMerge withConcurrency​(int concurrency)
      Indicates that the merge process can consume up to concurrency streams concurrently.
      MultiMerge withRequests​(int requests)
      Indicates that the merge process should consume the different streams using the given request.
      • Methods inherited from class java.lang.Object

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

      • streams

        @SafeVarargs
        @CheckReturnValue
        public final <T> Multi<T> streams​(org.reactivestreams.Publisher<T>... publishers)
        Creates a new Multi merging the items emitted by the given multis / publishers.

        If you pass no publishers, the resulting Multi emits the completion event immediately after subscription. If you pass a single publisher, the resulting Multi emits the events from that publisher. If you pass multiple publishers, the resulting Multi emits the events from the publishers, until all the publishers completes. When the last publisher completes, it sends the completion event.

        If any of the publisher emits a failure, the failure is passed downstream and the merge stops. This behavior can be changed using collectFailures(). In this case, the failures are accumulated and would be propagated instead of the final completion event. If multiple failures have been collected, the downstream receives a CompositeException, otherwise it receives the collected failure. IMPORTANT: Unlike concatenation, the order of the publisher does not matter and items from several upstream publishers can be interleaved in the resulting Multi.

        Type Parameters:
        T - the type of item
        Parameters:
        publishers - the publishers, can be empty, must not contain null
        Returns:
        the new Multi merging the passed publisher, so emitting the items from these publishers.
      • streams

        @CheckReturnValue
        public <T> Multi<T> streams​(java.lang.Iterable<? extends org.reactivestreams.Publisher<T>> iterable)
        Creates a new Multi merging the items emitted by the given publishers / publishers.

        If you pass no publishers, the resulting Multi emits the completion event immediately after subscription. If you pass a single publisher, the resulting Multi emits the events from that publisher. If you pass multiple publishers, the resulting Multi emits the events from the publishers, until all the publishers completes. When the last publisher completes, it sends the completion event.

        If any of the publisher emits a failure, the failure is passed downstream and the merge stops. This behavior can be changed using collectFailures(). In this case, the failures are accumulated and would be propagated instead of the final completion event. If multiple failures have been collected, the downstream receives a CompositeException, otherwise it receives the collected failure. IMPORTANT: Unlike concatenation, the order of the publisher does not matter and items from several upstream publishers can be interleaved in the resulting Multi.

        Type Parameters:
        T - the type of item
        Parameters:
        iterable - the published, must not be empty, must not contain null, must not be null
        Returns:
        the new Multi emitting the items from the given set of Publisher
      • collectFailures

        @CheckReturnValue
        public MultiMerge collectFailures()
        Indicates that the merge process should not propagate the first received failure, but collect them until all the items from all (non-failing) participants have been emitted. Then, the failures are propagated downstream (as a CompositeException if several failures have been received).
        Returns:
        a new MultiMerge collecting failures
      • withRequests

        @CheckReturnValue
        public MultiMerge withRequests​(int requests)
        Indicates that the merge process should consume the different streams using the given request.
        Parameters:
        requests - the request
        Returns:
        a new MultiMerge configured with the given requests
      • withConcurrency

        @CheckReturnValue
        public MultiMerge withConcurrency​(int concurrency)
        Indicates that the merge process can consume up to concurrency streams concurrently. Items emitted by these streams may be interleaved in the resulting stream.
        Parameters:
        concurrency - the concurrency
        Returns:
        a new MultiMerge configured with the given concurrency