kafka-avro-console-consumer should support different deserializers for key and value, instead of assuming that key _and_ value are Avro.
E.g. we have many topics w/ string key and Avro value. kafka-avro-console-consumer can't print the keys.
kafka-avro-console-consumer (or more specifically AvroMessageFormatter) doesn鈥檛 accept key.deserializer property like kafka-console-consumer (or more specifically DefaultMessageFormatter).
This means that we can鈥檛 deserialize a topic where messages are non-Avro (e.g. String) and values are Avro with --property print.key=true.
kafka-avro-console-consumer to consume messages from the topic@xiongtx would you like to take it forward? you can may be optionally accept a key deserializer and if not present assume avro.
kafka-avro-console-consumer even has an option --key-deserializer (at least output of kafka-avro-console-consumer -h says so) but that doesn't work neither. It always uses org.apache.kafka.common.serialization.ByteArrayDeserializer.
Options I tried:
--property 'key.deserializer=org.apache.kafka.common.serialization.StringDeserializer'
--key-deserializer org.apache.kafka.common.serialization.StringDeserializer
It works fine in my environment. Try to put the equal sign between '--key-deserializer' and the value.
Example:
kafka-avro-console-consumer --topic MyTopic --zookeeper localhost:2181 --property print.key=true --key-deserializer=org.apache.kafka.common.serialization.StringDeserializer
This issue has been resolved.
@rayokota Can you, please, reopen this one or create another one (because it can be not related) or explain what is going wrong
I have docker setup of _zookeeper,kafka,schemaregisry_ of official version 5.4.1
I go to _schemaregisry_ container and tried to execute different queries, f.e:
/usr/bin/kafka-avro-console-consumer --bootstrap-server kafka:9092 --topic Identity.TestCreateLifecycleEvents --value-deserializer=io.confluent.kafka.serializers.KafkaAvroDeserializer --property schema.registry.url=http://schemaregistry:8081 --property value.deserializer=io.confluent.kafka.serializers.KafkaAvroDeserializer
or
docker exec -it les-schema bash -c "/usr/bin/kafka-avro-console-consumer --bootstrap-server kafka:9092 --topic Identity.TestCreateLifecycleEvents --value-deserializerio.confluent.kafka.serializers.KafkaAvroDeserializer --property schema.registry.url='http://schemaregistry:8081' --property value.deserializer=io.confluent.kafka.serializers.KafkaAvroDeserializer"
And everytime my consumer is initialized with value.deserializer = class org.apache.kafka.common.serialization.ByteArrayDeserializer, question is why?
Most helpful comment
It works fine in my environment. Try to put the equal sign between '--key-deserializer' and the value.
Example:
kafka-avro-console-consumer --topic MyTopic --zookeeper localhost:2181 --property print.key=true --key-deserializer=org.apache.kafka.common.serialization.StringDeserializer