Class MonoUtils

java.lang.Object
org.axonframework.messaging.core.MonoUtils

public abstract class MonoUtils extends Object
Utility methods to work with Project Reactor's monos.
Since:
5.0.0
Author:
John Hendrikx
  • Method Details

    • asSingle

      public static <M extends Message> MessageStream.Single<M> asSingle(@Nonnull reactor.core.publisher.Mono<M> mono)
      Create a stream that returns a single
      invalid reference
      entry
      wrapping the Message from the given mono, once the given mono completes.

      The stream will contain at most a single entry. It may also contain no entries if the mono completes empty. The stream will complete with an exception when the given mono completes exceptionally.

      Type Parameters:
      M - The type of Message contained in the
      invalid reference
      entries
      of this stream.
      Parameters:
      mono - The Mono providing the Message to contain in the stream.
      Returns:
      A stream containing at most one
      invalid reference
      entry
      from the given mono.
    • asSingle

      public static <M extends Message> MessageStream.Single<M> asSingle(@Nonnull reactor.core.publisher.Mono<M> mono, @Nonnull Function<M,Context> contextSupplier)
      Create a stream that returns a single
      invalid reference
      entry
      wrapping the Message from the given mono, once the given mono completes.

      The automatically generated Entry will have the Context as given by the contextSupplier.

      The stream will contain at most a single entry. It may also contain no entries if the mono completes empty. The stream will complete with an exception when the given mono completes exceptionally.

      Type Parameters:
      M - The type of Message contained in the
      invalid reference
      entries
      of this stream.
      Parameters:
      mono - The Mono providing the Message to contain in the stream.
      contextSupplier - A Function ingesting the Message from the given mono returning the Context to set for the
      invalid reference
      Entry
      the Message is wrapped in.
      Returns:
      A stream containing at most one
      invalid reference
      entry
      from the given mono.