接口 MessagePayloadContext
-
public interface MessagePayloadContextThe context of the message payload, which usually represents a batched message (batch) or a single message.
-
-
方法概要
所有方法 实例方法 抽象方法 修饰符和类型 方法 说明 <T> Message<T>asSingleMessage(MessagePayload payload, Schema<T> schema)Convert the given payload to a single message if the entry is not a batch.<T> Message<T>getMessageAt(int index, int numMessages, MessagePayload payload, boolean containMetadata, Schema<T> schema)Get the internal single message with a specific index from a payload if the payload is a batch.intgetNumMessages()Get the number of messages when the payload is produced by Pulsar producer.java.lang.StringgetProperty(java.lang.String key)Get a value associated with the given key.booleanisBatch()Check whether the payload is a batch when the payload is produced by Pulsar producer.
-
-
-
方法详细资料
-
getProperty
java.lang.String getProperty(java.lang.String key)
Get a value associated with the given key. When the message payload is not produced by Pulsar producer, a specific property is usually added to indicate the format. So this method is useful to determine whether the payload is produced by Pulsar producer.- 参数:
key-- 返回:
- the value associated with the key or null if the key or value doesn't exist
-
getNumMessages
int getNumMessages()
Get the number of messages when the payload is produced by Pulsar producer.- 返回:
- the number of messages
-
isBatch
boolean isBatch()
Check whether the payload is a batch when the payload is produced by Pulsar producer.- 返回:
- true if the payload is a batch
-
getMessageAt
<T> Message<T> getMessageAt(int index, int numMessages, MessagePayload payload, boolean containMetadata, Schema<T> schema)
Get the internal single message with a specific index from a payload if the payload is a batch.- 类型参数:
T-- 参数:
index- the batch indexnumMessages- the number of messages in the batchpayload- the message payloadcontainMetadata- whether the payload contains the single message metadataschema- the schema of the batch- 返回:
- the created message
-
asSingleMessage
<T> Message<T> asSingleMessage(MessagePayload payload, Schema<T> schema)
Convert the given payload to a single message if the entry is not a batch.- 类型参数:
T-- 参数:
payload- the message payloadschema- the schema of the message- 返回:
- the created message
-
-