Interface PulsarMessageMetadata
- All Known Implementing Classes:
PulsarIncomingMessageMetadata
public interface PulsarMessageMetadata
-
Method Summary
Modifier and TypeMethodDescriptionGet broker publish time from broker entry metadata.longGet the event time associated with this message.getIndex()Get index from broker entry metadata.getKey()Get the key of the message.byte[]Get bytes in key.byte[]Get the ordering key of the message.Return the properties attached to the message.getProperty(String name) Get the value of a specific property.longGet the publish time of this message.intGet message redelivery count, redelivery count maintain in pulsar broker.Get name of cluster, from which the message is replicated.byte[]Get schema version of the message.Get the topic the message was published to.booleanCheck whether the key has been base64 encoded.booleanCheck whether the message has a broker publish timebooleanhasIndex()Check whether the message has an index.booleanhasKey()Check whether the message has a key.booleanCheck whether the message has a ordering key.booleanhasProperty(String name) Check whether the message has a specific property attached.booleanCheck whether the message is replicated from other cluster.intsize()Get the uncompressed message payload size in bytes.
-
Method Details
-
getProperties
Return the properties attached to the message.Properties are application defined key/value pairs that will be attached to the message.
- Returns:
- an unmodifiable view of the properties map
-
hasProperty
Check whether the message has a specific property attached.- Parameters:
name- the name of the property to check- Returns:
- true if the message has the specified property and false if the properties is not defined
-
getProperty
Get the value of a specific property.- Parameters:
name- the name of the property- Returns:
- the value of the property or null if the property was not defined
-
size
int size()Get the uncompressed message payload size in bytes.- Returns:
- size in bytes.
-
getPublishTime
long getPublishTime()Get the publish time of this message. The publish time is the timestamp that a client publish the message.- Returns:
- publish time of this message.
- See Also:
-
getEventTime
long getEventTime()Get the event time associated with this message.If there isn't any event time associated with this event, it will return 0.
- Returns:
- the message event time or 0 if event time wasn't set
-
hasKey
boolean hasKey()Check whether the message has a key.- Returns:
- true if the key was set while creating the message and false if the key was not set while creating the message
-
getKey
String getKey()Get the key of the message.- Returns:
- the key of the message
-
hasBase64EncodedKey
boolean hasBase64EncodedKey()Check whether the key has been base64 encoded.- Returns:
- true if the key is base64 encoded, false otherwise
-
getKeyBytes
byte[] getKeyBytes()Get bytes in key. If the key has been base64 encoded, it is decoded before being returned. Otherwise, if the key is a plain string, this method returns the UTF_8 encoded bytes of the string.- Returns:
- the key in byte[] form
-
hasOrderingKey
boolean hasOrderingKey()Check whether the message has a ordering key.- Returns:
- true if the ordering key was set while creating the message false if the ordering key was not set while creating the message
-
getOrderingKey
byte[] getOrderingKey()Get the ordering key of the message.- Returns:
- the ordering key of the message
-
getTopicName
String getTopicName()Get the topic the message was published to.- Returns:
- the topic the message was published to
-
getRedeliveryCount
int getRedeliveryCount()Get message redelivery count, redelivery count maintain in pulsar broker. When client acknowledge message timeout, broker will dispatch message again with message redelivery count in CommandMessage defined.Message redelivery increases monotonically in a broker, when topic switch ownership to a another broker redelivery count will be recalculated.
- Returns:
- message redelivery count
-
getSchemaVersion
byte[] getSchemaVersion()Get schema version of the message.- Returns:
- Schema version of the message if the message is produced with schema otherwise null.
-
isReplicated
boolean isReplicated()Check whether the message is replicated from other cluster.- Returns:
- true if the message is replicated from other cluster. false otherwise.
-
getReplicatedFrom
String getReplicatedFrom()Get name of cluster, from which the message is replicated.- Returns:
- the name of cluster, from which the message is replicated.
-
hasBrokerPublishTime
boolean hasBrokerPublishTime()Check whether the message has a broker publish time- Returns:
- true if the message has a broker publish time, otherwise false.
-
getBrokerPublishTime
Get broker publish time from broker entry metadata. Note that only if the feature is enabled in the broker then the value is available.- Returns:
- broker publish time from broker entry metadata, or empty if the feature is not enabled in the broker.
-
hasIndex
boolean hasIndex()Check whether the message has an index.- Returns:
- true if the message has an index, otherwise false.
-
getIndex
Get index from broker entry metadata. Note that only if the feature is enabled in the broker then the value is available.- Returns:
- index from broker entry metadata, or empty if the feature is not enabled in the broker.
-