public class ProtobufMessageFormatter extends SchemaMessageFormatter<com.google.protobuf.Message>
1. To read only the value of the messages in JSON bin/kafka-console-consumer.sh --consumer.config config/consumer.properties --topic t1 \ --bootstrap-server localhost:9092 --formatter io.confluent.kafka.formatter.ProtobufMessageFormatter \ --property schema.registry.url=http://localhost:8081
2. To read both the key and the value of the messages in JSON bin/kafka-console-consumer.sh --consumer.config config/consumer.properties --topic t1 \ --bootstrap-server localhost:9092 --formatter io.confluent.kafka.formatter.ProtobufMessageFormatter \ --property schema.registry.url=http://localhost:8081 \ --property print.key=true
3. To read the key, value, and timestamp of the messages in JSON bin/kafka-console-consumer.sh --consumer.config config/consumer.properties --topic t1 \ --bootstrap-server localhost:9092 --formatter io.confluent.kafka.formatter.ProtobufMessageFormatter \ --property schema.registry.url=http://localhost:8081 \ --property print.key=true \ --property print.timestamp=true
deserializer| Constructor and Description |
|---|
ProtobufMessageFormatter()
Constructor needed by kafka console consumer.
|
| Modifier and Type | Method and Description |
|---|---|
protected SchemaMessageDeserializer<com.google.protobuf.Message> |
createDeserializer(org.apache.kafka.common.serialization.Deserializer keyDeserializer) |
protected SchemaProvider |
getProvider() |
void |
init(Properties props) |
protected void |
writeTo(String topic,
Boolean isKey,
org.apache.kafka.common.header.Headers headers,
byte[] data,
PrintStream output) |
close, configure, writeTopublic ProtobufMessageFormatter()
protected SchemaMessageDeserializer<com.google.protobuf.Message> createDeserializer(org.apache.kafka.common.serialization.Deserializer keyDeserializer)
createDeserializer in class SchemaMessageFormatter<com.google.protobuf.Message>public void init(Properties props)
init in class SchemaMessageFormatter<com.google.protobuf.Message>protected void writeTo(String topic, Boolean isKey, org.apache.kafka.common.header.Headers headers, byte[] data, PrintStream output) throws IOException
writeTo in class SchemaMessageFormatter<com.google.protobuf.Message>IOExceptionprotected SchemaProvider getProvider()
getProvider in class SchemaMessageFormatter<com.google.protobuf.Message>Copyright © 2025 Confluent, Inc.. All rights reserved.