Package org.apache.pulsar.common.api.raw
Class RawMessageImpl
- java.lang.Object
-
- org.apache.pulsar.common.api.raw.RawMessageImpl
-
- All Implemented Interfaces:
RawMessage
public class RawMessageImpl extends java.lang.Object implements RawMessage
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static RawMessageget(ReferenceCountedMessageMetadata msgMetadata, SingleMessageMetadata singleMessageMetadata, io.netty.buffer.ByteBuf payload, long ledgerId, long entryId, long batchIndex)intgetBatchSize()io.netty.buffer.ByteBufgetData()Get the content of the message.longgetEventTime()Get the event time associated with this message.java.util.Optional<java.lang.String>getKey()Get the key of the message.java.util.Optional<io.netty.buffer.ByteBuf>getKeyBytes()Get byteBuf of the key.RawMessageIdgetMessageId()Get the unique message ID associated with this message.java.lang.StringgetProducerName()Get the producer name who produced this message.java.util.Map<java.lang.String,java.lang.String>getProperties()Return the properties attached to the message.longgetPublishTime()Get the publish time of this message.byte[]getSchemaVersion()Get the schema verison of the message.longgetSequenceId()Get the sequence id associated with this message.booleanhasBase64EncodedKey()Check whether the key has been base64 encoded.voidrelease()Release all the resources associated with this raw message.
-
-
-
Method Detail
-
release
public void release()
Description copied from interface:RawMessageRelease all the resources associated with this raw message.- Specified by:
releasein interfaceRawMessage
-
get
public static RawMessage get(ReferenceCountedMessageMetadata msgMetadata, SingleMessageMetadata singleMessageMetadata, io.netty.buffer.ByteBuf payload, long ledgerId, long entryId, long batchIndex)
-
getProperties
public java.util.Map<java.lang.String,java.lang.String> getProperties()
Description copied from interface:RawMessageReturn the properties attached to the message.Properties are application defined key/value pairs that will be attached to the message.
- Specified by:
getPropertiesin interfaceRawMessage- Returns:
- an unmodifiable view of the properties map
-
getData
public io.netty.buffer.ByteBuf getData()
Description copied from interface:RawMessageGet the content of the message.- Specified by:
getDatain interfaceRawMessage- Returns:
- the byte array with the message payload
-
getMessageId
public RawMessageId getMessageId()
Description copied from interface:RawMessageGet the unique message ID associated with this message.The message id can be used to univocally refer to a message without having the keep the entire payload in memory.
Only messages received from the consumer will have a message id assigned.
- Specified by:
getMessageIdin interfaceRawMessage- Returns:
- the message id null if this message was not received by this client instance
-
getPublishTime
public long getPublishTime()
Description copied from interface:RawMessageGet the publish time of this message. The publish time is the timestamp that a client publish the message.- Specified by:
getPublishTimein interfaceRawMessage- Returns:
- publish time of this message.
- See Also:
RawMessage.getEventTime()
-
getEventTime
public long getEventTime()
Description copied from interface:RawMessageGet the event time associated with this message. It is typically set by the applications viaMessageBuilder#setEventTime(long).If there isn't any event time associated with this event, it will return 0.
- Specified by:
getEventTimein interfaceRawMessage
-
getSequenceId
public long getSequenceId()
Description copied from interface:RawMessageGet the sequence id associated with this message. It is typically set by the applications viaMessageBuilder#setSequenceId(long).- Specified by:
getSequenceIdin interfaceRawMessage- Returns:
- sequence id associated with this message.
- See Also:
MessageBuilder#setEventTime(long)
-
getProducerName
public java.lang.String getProducerName()
Description copied from interface:RawMessageGet the producer name who produced this message.- Specified by:
getProducerNamein interfaceRawMessage- Returns:
- producer name who produced this message, null if producer name is not set.
-
getKey
public java.util.Optional<java.lang.String> getKey()
Description copied from interface:RawMessageGet the key of the message.- Specified by:
getKeyin interfaceRawMessage- Returns:
- the key of the message
-
getSchemaVersion
public byte[] getSchemaVersion()
Description copied from interface:RawMessageGet the schema verison of the message.- Specified by:
getSchemaVersionin interfaceRawMessage- Returns:
- the schema version of the message
-
getKeyBytes
public java.util.Optional<io.netty.buffer.ByteBuf> getKeyBytes()
Description copied from interface:RawMessageGet byteBuf of the key.- Specified by:
getKeyBytesin interfaceRawMessage- Returns:
- the byte array with the key payload
-
hasBase64EncodedKey
public boolean hasBase64EncodedKey()
Description copied from interface:RawMessageCheck whether the key has been base64 encoded.- Specified by:
hasBase64EncodedKeyin interfaceRawMessage- Returns:
- true if the key is base64 encoded, false otherwise
-
getBatchSize
public int getBatchSize()
-
-