Class Messages

java.lang.Object
io.smallrye.reactive.messaging.Messages

public class Messages extends Object
A class handling coordination between messages.
  • Method Details

    • chain

      @CheckReturnValue public static Messages.MessageChainBuilder chain(Message<?> message)
      Chains the given message with some other messages. It coordinates the acknowledgement. When all the other messages are acknowledged successfully, the passed message is acknowledged. If one of the other messages is acknowledged negatively, the passed message is also nacked (with the same reason). Subsequent ack/nack will be ignored.

      Parameters:
      message - the message
      Returns:
      the chain builder that let you decide how the metadata are passed, and the set of messages.
    • merge

      public static <T> Message<T> merge(List<Message<?>> list, Function<List<?>,T> combinator)
      Merges multiple messages into a single one. This is an implementation of a merge pattern: n messages combined into 1.

      Whe resulting message payload is computed using the combinator function. When the returned message is acked/nacked, the passes messages are acked/nacked accordingly.

      Metadata are also merged. The metadata of all the messages are copied into the resulting message. If, for a given class, the metadata is already present in the result message, it's either ignored, or merged if the class implements MergeableMetadata.

      Type Parameters:
      T - the payload type of the produced message
      Parameters:
      list - the list of message, must not be empty, must not be null
      combinator - the combinator method, must not be null
      Returns:
      the resulting message
    • merge

      public static <T> Message<List<T>> merge(List<Message<T>> list)
      Merges multiple messages into a single one.

      Whe resulting message payload is computed using the combinator function. When the returned message is acked/nacked, the passes messages are acked/nacked accordingly.

      Metadata are also merged. The metadata of all the messages are copied into the resulting message. If, for a given class, the metadata is already present in the result message, it's either ignored, or merged if the class implements MergeableMetadata.

      Type Parameters:
      T - the payload type of the passed messages
      Parameters:
      list - the list of message, must not be empty, must not be null
      Returns:
      the resulting message