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.
限定符和类型 | 字段和说明 |
---|---|
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
|
限定符和类型 | 方法和说明 |
---|---|
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–2019 Apache Software Foundation. All rights reserved.