接口 MessagePayloadProcessor
public interface MessagePayloadProcessor
The processor to process a message payload.
It's responsible to convert the raw buffer to some messages, then trigger some callbacks so that consumer can consume
these messages and handle the exception if it existed.
The most important part is to decode the raw buffer. After that, we can call
MessagePayloadContext.getMessageAt(int, int, org.apache.pulsar.client.api.MessagePayload, boolean, org.apache.pulsar.client.api.Schema<T>)
or MessagePayloadContext.asSingleMessage(org.apache.pulsar.client.api.MessagePayload, org.apache.pulsar.client.api.Schema<T>)
to construct
Message
for consumer to consume. Since we need to pass the MessagePayload
object to these methods, we
can use MessagePayloadFactory.DEFAULT
to create it or just reuse the payload argument.-
字段概要
字段 -
方法概要
修饰符和类型方法说明<T> void
process
(MessagePayload payload, MessagePayloadContext context, Schema<T> schema, Consumer<Message<T>> messageConsumer) Process the message payload.
-
字段详细资料
-
DEFAULT
-
-
方法详细资料
-
process
<T> void process(MessagePayload payload, MessagePayloadContext context, Schema<T> schema, Consumer<Message<T>> messageConsumer) throws Exception Process the message payload.- 类型参数:
T
-- 参数:
payload
- the payload whose underlying buffer is a Netty ByteBufcontext
- the message context that contains the message format information and methods to create a messageschema
- the message's schemamessageConsumer
- the callback to consume each message- 抛出:
Exception
-