Package org.apache.pulsar.client.api
Interface 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 callMessagePayloadContext.getMessageAt(int, int, org.apache.pulsar.client.api.MessagePayload, boolean, org.apache.pulsar.client.api.Schema<T>)
orMessagePayloadContext.asSingleMessage(org.apache.pulsar.client.api.MessagePayload, org.apache.pulsar.client.api.Schema<T>)
to constructMessage
for consumer to consume. Since we need to pass theMessagePayload
object to these methods, we can useMessagePayloadFactory.DEFAULT
to create it or just reuse the payload argument.
-
-
Field Summary
Fields Modifier and Type Field Description static MessagePayloadProcessor
DEFAULT
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description <T> void
process(MessagePayload payload, MessagePayloadContext context, Schema<T> schema, java.util.function.Consumer<Message<T>> messageConsumer)
Process the message payload.
-
-
-
Field Detail
-
DEFAULT
static final MessagePayloadProcessor DEFAULT
-
-
Method Detail
-
process
<T> void process(MessagePayload payload, MessagePayloadContext context, Schema<T> schema, java.util.function.Consumer<Message<T>> messageConsumer) throws java.lang.Exception
Process the message payload.- Type Parameters:
T
-- Parameters:
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- Throws:
java.lang.Exception
-
-