public class AvroMessageFormatter extends SchemaMessageFormatter<Object>
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
deserializer| Constructor and Description |
|---|
AvroMessageFormatter()
Constructor needed by kafka console consumer.
|
| Modifier and Type | Method and Description |
|---|---|
protected SchemaMessageDeserializer<Object> |
createDeserializer(org.apache.kafka.common.serialization.Deserializer keyDeserializer) |
protected SchemaProvider |
getProvider() |
protected void |
writeTo(String topic,
Boolean isKey,
org.apache.kafka.common.header.Headers headers,
byte[] data,
PrintStream output) |
close, configure, init, writeTopublic AvroMessageFormatter()
protected SchemaMessageDeserializer<Object> createDeserializer(org.apache.kafka.common.serialization.Deserializer keyDeserializer)
createDeserializer in class SchemaMessageFormatter<Object>protected void writeTo(String topic, Boolean isKey, org.apache.kafka.common.header.Headers headers, byte[] data, PrintStream output) throws IOException
writeTo in class SchemaMessageFormatter<Object>IOExceptionprotected SchemaProvider getProvider()
getProvider in class SchemaMessageFormatter<Object>Copyright © 2025 Confluent, Inc.. All rights reserved.