Package org.apache.pulsar.client.api.v5
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 TypeMethodDescriptionbyte[]data()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.intThe number of times the broker has redelivered this message.The cluster from which this message was replicated, if applicable.longThe producer-assigned sequence ID for deduplication.intsize()The uncompressed size of the message payload in bytes.topic()The topic this message was published to.value()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
MessageIdof this message
-
key
The message key, used for per-key ordering.- Returns:
- an
Optionalcontaining the message key, or empty if no key was set
-
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
The event time set by the producer, if any.- Returns:
- an
Optionalcontaining 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
The name of the producer that published this message.- Returns:
- an
Optionalcontaining 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
The cluster from which this message was replicated, if applicable.- Returns:
- an
Optionalcontaining the source cluster name, or empty if the message is not replicated
-