Class AvroMessageFormatter
- All Implemented Interfaces:
Closeable,AutoCloseable,org.apache.kafka.common.Configurable,org.apache.kafka.common.MessageFormatter
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
-
Field Summary
Fields inherited from class io.confluent.kafka.formatter.SchemaMessageFormatter
deserializer -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected SchemaMessageDeserializer<Object>createDeserializer(org.apache.kafka.common.serialization.Deserializer keyDeserializer) protected SchemaProviderprotected voidwriteTo(String topic, Boolean isKey, org.apache.kafka.common.header.Headers headers, byte[] data, PrintStream output) Methods inherited from class io.confluent.kafka.formatter.SchemaMessageFormatter
close, configure, init, writeTo
-
Constructor Details
-
AvroMessageFormatter
public AvroMessageFormatter()Constructor needed by kafka console consumer.
-
-
Method Details
-
createDeserializer
protected SchemaMessageDeserializer<Object> createDeserializer(org.apache.kafka.common.serialization.Deserializer keyDeserializer) - Specified by:
createDeserializerin classSchemaMessageFormatter<Object>
-
writeTo
protected void writeTo(String topic, Boolean isKey, org.apache.kafka.common.header.Headers headers, byte[] data, PrintStream output) throws IOException - Specified by:
writeToin classSchemaMessageFormatter<Object>- Throws:
IOException
-
getProvider
- Specified by:
getProviderin classSchemaMessageFormatter<Object>
-