public interface MessageId extends Comparable<MessageId>, Serializable
The MessageId can be used to reference a specific message, for example when acknowledging, without having to retain the message content in memory for an extended period of time.
Message ids are Comparable
and a bigger message id will imply that a message was published "after"
the other one.
Modifier and Type | Field and Description |
---|---|
static MessageId |
earliest
MessageId that represents the oldest message available in the topic.
|
static MessageId |
latest
MessageId that represents the next message published in the topic.
|
Modifier and Type | Method and Description |
---|---|
static MessageId |
fromByteArray(byte[] data)
De-serialize a message id from a byte array.
|
static MessageId |
fromByteArrayWithTopic(byte[] data,
String topicName)
De-serialize a message id from a byte array with its topic
information attached.
|
byte[] |
toByteArray()
Serialize the message ID into a byte array.
|
compareTo
static final MessageId earliest
static final MessageId latest
byte[] toByteArray()
The serialized message id can be stored away and later get deserialized by
using fromByteArray(byte[])
.
static MessageId fromByteArray(byte[] data) throws IOException
data
- byte array containing the serialized message idIOException
- if the de-serialization failsstatic MessageId fromByteArrayWithTopic(byte[] data, String topicName) throws IOException
The topic information is needed when acknowledging a MessageId
on
a consumer that is consuming from multiple topics.
data
- the byte array with the serialized message idtopicName
- the topic nameinstance
IOException
- if the de-serialization failsCopyright © 2017–2020 Apache Software Foundation. All rights reserved.