Class MultiConcat

java.lang.Object
io.smallrye.mutiny.groups.MultiConcat

public class MultiConcat extends Object
Creates new Multi by concatenating several Multi or Flow.Publisher. This class allows configuring how the concatenation is executed. Unlike a merge, a concatenation emits the items in order. Streams are read one-by-one and the items are emitted in this order.
  • Constructor Details

    • MultiConcat

      public MultiConcat(boolean collectFailures)
  • Method Details

    • streams

      @SafeVarargs @CheckReturnValue public final <T> Multi<T> streams(Flow.Publisher<T>... publishers)
      Creates a new Multi concatenating 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 first publisher. When this one emits the completion event, it drops that event and emits the events from the next publisher and so on until it reaches the last publisher. When the last publisher is consumed, it sends the completion event.

      If any of the publisher emits a failure, the failure is passed downstream and the concatenation 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: The order of the publisher matters.

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

      @CheckReturnValue public <T> Multi<T> streams(Iterable<? extends Flow.Publisher<T>> iterable)
      Creates a new Multi concatenating 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 first publisher. When this one emits the completion event, it drops that event and emits the events from the second publisher and so on until it reaches the last publisher. When the last publisher is consumed, it sends the completion event.

      If any of the publisher emits a failure, the failure is passed downstream and the concatenation 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: The order of the publisher matters.

      Type Parameters:
      T - the type of item
      Parameters:
      iterable - the publishers, can be empty, must not contain null, must not be null
      Returns:
      the new Multi emitting the items from the given set of Multi concatenating the passed publishers.
    • collectFailures

      @CheckReturnValue public MultiConcat collectFailures()
      Indicates that the concatenation 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:
      this MultiConcat configured to collect the failures.