Class ProtobufMessageFormatter

java.lang.Object
io.confluent.kafka.formatter.SchemaMessageFormatter<com.google.protobuf.Message>
io.confluent.kafka.formatter.protobuf.ProtobufMessageFormatter
All Implemented Interfaces:
Closeable, AutoCloseable, org.apache.kafka.common.Configurable, org.apache.kafka.common.MessageFormatter

public class ProtobufMessageFormatter extends SchemaMessageFormatter<com.google.protobuf.Message>
Example To use ProtobufMessageFormatter, first make sure that Zookeeper, Kafka and schema registry server are all started. Second, make sure the jar for ProtobufMessageFormatter and its dependencies are included in the classpath of kafka-console-consumer.sh. Then run the following command.

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