Class ProtobufMessageFormatter
- 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.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
-
Field Summary
Fields inherited from class io.confluent.kafka.formatter.SchemaMessageFormatter
deserializer -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected SchemaMessageDeserializer<com.google.protobuf.Message>createDeserializer(org.apache.kafka.common.serialization.Deserializer keyDeserializer) protected SchemaProvidervoidinit(Properties props) protected 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, writeTo
-
Constructor Details
-
ProtobufMessageFormatter
public ProtobufMessageFormatter()Constructor needed by kafka console consumer.
-
-
Method Details
-
createDeserializer
protected SchemaMessageDeserializer<com.google.protobuf.Message> createDeserializer(org.apache.kafka.common.serialization.Deserializer keyDeserializer) - Specified by:
createDeserializerin classSchemaMessageFormatter<com.google.protobuf.Message>
-
init
- Overrides:
initin classSchemaMessageFormatter<com.google.protobuf.Message>
-
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<com.google.protobuf.Message>- Throws:
IOException
-
getProvider
- Specified by:
getProviderin classSchemaMessageFormatter<com.google.protobuf.Message>
-