Class MessageUtils

java.lang.Object
org.springframework.pulsar.reactive.support.MessageUtils

public final class MessageUtils extends Object
Convenience functions related to Spring messages.
Author:
Chris Bono
  • Method Details

    • extractMessageId

      public static <T> org.apache.pulsar.client.api.MessageId extractMessageId(Message<T> message)
      Determine the Pulsar MessageId for a given Spring message by extracting the value of its PulsarHeaders.MESSAGE_ID header.
      Type Parameters:
      T - the type of message payload
      Parameters:
      message - the Spring message
      Returns:
      the Pulsar message id
      Throws:
      IllegalStateException - if the message id could not be determined
    • acknowledge

      public static <T> org.apache.pulsar.reactive.client.api.MessageResult<Void> acknowledge(Message<T> message)
      Convenience method that acknowledges a Spring message by extracting its message id and passing it to MessageResult.acknowledge(MessageId).
      Type Parameters:
      T - the type of message payload
      Parameters:
      message - the Spring message to acknowledge
      Returns:
      an empty value and signals that the message must be acknowledged
    • negativeAcknowledge

      public static <T> org.apache.pulsar.reactive.client.api.MessageResult<Void> negativeAcknowledge(Message<T> message)
      Convenience method that negatively acknowledges a Spring message by extracting its message id and passing it to MessageResult.negativeAcknowledge(MessageId).
      Type Parameters:
      T - the type of message payload
      Parameters:
      message - the Spring message to negatively acknowledge
      Returns:
      an empty value and signals that the message must be negatively acknowledged