1
votes

Trying to consume kafka Avro messages from console consumer and not exactly sure how to deserialize the messages.

sh /usr/hdp/current/kafka-broker/bin/kafka-console-consumer.sh --bootstrap-server localhost:6667 --topic test --consumer.config /home/user/kafka.consumer.properties --from-beginning --value-deserializer ByteArrayDeserializer

The Avro Schema in Schema Registry for the test topic is:

{
 "type": "record",
 "namespace": "test",
 "name": "TestRecord",
 "fields": [
  {
   "name": "Name",
   "type": "string",
   "default": "null"
  },
  {
   "name": "Age",
   "type": "int",
   "default": -1
  }
 ]
}

Using HDP 3.1 version and Kafka-clients-2.0.0.3.1.0.0-78

Could someone help me what would be the Deserializer required to read Avro messages from console.

1

1 Answers

2
votes

Use kafka-avro-console-consumer

e.g.

sh /usr/hdp/current/kafka-broker/bin/kafka-avro-console-consumer.sh \
--bootstrap-server localhost:6667 \
--topic test \
--from-beginning \
--property schema.registry.url=http://localhost:8081