Interface Message<T>

Type Parameters:
T - the type of the deserialized message value

public interface Message<T>
An immutable message received from a Pulsar topic.
  • Method Summary

    Modifier and Type
    Method
    Description
    byte[]
    The raw bytes of the message payload.
    The event time set by the producer, if any.
    id()
    The unique identifier of this message within the topic.
    key()
    The message key, used for per-key ordering.
    The name of the producer that published this message.
    Application-defined properties attached to the message.
    The timestamp when the message was published by the broker.
    int
    The number of times the broker has redelivered this message.
    The cluster from which this message was replicated, if applicable.
    long
    The producer-assigned sequence ID for deduplication.
    int
    The uncompressed size of the message payload in bytes.
    The topic this message was published to.
    The deserialized value of the message according to the schema.
  • Method Details

    • value

      T value()
      The deserialized value of the message according to the schema.
      Returns:
      the deserialized message value
    • data

      byte[] data()
      The raw bytes of the message payload.
      Returns:
      the raw payload as a byte array
    • id

      MessageId id()
      The unique identifier of this message within the topic.
      Returns:
      the MessageId of this message
    • key

      The message key, used for per-key ordering.
      Returns:
      an Optional containing the message key, or empty if no key was set
    • properties

      Map<String,String> properties()
      Application-defined properties attached to the message.
      Returns:
      an unmodifiable map of property key-value pairs
    • publishTime

      Instant publishTime()
      The timestamp when the message was published by the broker.
      Returns:
      the publish timestamp as an Instant
    • eventTime

      Optional<Instant> eventTime()
      The event time set by the producer, if any.
      Returns:
      an Optional containing the event time, or empty if not set by the producer
    • sequenceId

      long sequenceId()
      The producer-assigned sequence ID for deduplication.
      Returns:
      the sequence ID of this message
    • producerName

      Optional<String> producerName()
      The name of the producer that published this message.
      Returns:
      an Optional containing the producer name, or empty if not available
    • topic

      String topic()
      The topic this message was published to.
      Returns:
      the fully qualified topic name
    • redeliveryCount

      int redeliveryCount()
      The number of times the broker has redelivered this message.
      Returns:
      the redelivery count, starting at 0 for the first delivery
    • size

      int size()
      The uncompressed size of the message payload in bytes.
      Returns:
      the payload size in bytes
    • replicatedFrom

      Optional<String> replicatedFrom()
      The cluster from which this message was replicated, if applicable.
      Returns:
      an Optional containing the source cluster name, or empty if the message is not replicated