Class AvroMessageFormatter

java.lang.Object
io.confluent.kafka.formatter.SchemaMessageFormatter<Object>
io.confluent.kafka.formatter.AvroMessageFormatter
All Implemented Interfaces:
Closeable, AutoCloseable, org.apache.kafka.common.Configurable, org.apache.kafka.common.MessageFormatter

public class AvroMessageFormatter extends SchemaMessageFormatter<Object>
Example To use AvroMessageFormatter, first make sure that Zookeeper, Kafka and schema registry server are all started. Second, make sure the jar for AvroMessageFormatter 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.AvroMessageFormatter \ --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.AvroMessageFormatter \ --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.AvroMessageFormatter \ --property schema.registry.url=http://localhost:8081 \ --property print.key=true \ --property print.timestamp=true