confluentinc / confluentinc/schema-registry
Avro deserialization success but cannot print the message
- Dominant language
- Java
- Stars
- 2.5k
- Forks
- 1.2k
- Avg merge
- 23h 27m
- Merged PRs (30d)
- 65
Description
I have a legacy C++ based system which spits out binary encoded Avro data that supports confluent Avro schema registry format. In my Java application, I successfully deserialized the message using KafkaAvroDeserializer class but could not print out the message.
`
private void consumeAvroData(){
String group = "group1";
Properties props = new Properties();
props.put("bootstrap.servers", "http://1.2.3.4:9092");
props.put("group.id", group);
props.put("enable.auto.commit", "true");
props.put("auto.commit.interval.ms", "1000");
props.put("session.timeout.ms", "30000");
props.put("key.deserializer", LongDeserializer.class.getName());
props.put("value.deserializer", KafkaAvroDeserializer.class.getName());
// props.put(KafkaAvroDeserializerConfig.SPECIFIC_AVRO_READER_CONFIG,"false");
props.put("schema.registry.url","http://1.2.3.4:8081");
KafkaConsumer consumer = new KafkaConsumer(props);
consumer.subscribe(Arrays.asList(TOPIC_NAME));
System.out.println("Subscribed to topic " + TOPIC_NAME);
while (true) {
ConsumerRecords records = consumer.poll(100);
for (ConsumerRecord record : records)
{
System.out.printf("value = %s\n",record.value());
}
}
}
`
The output I see is
`{"value":"�"}
`
Any help appreciated !
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with the consumeAvroData entry point and the KafkaAvroDeserializer configuration shown in the issue. Inspect the runtime type and schema of record.value() while comparing the decoded payload with the registered Avro schema. Done means explaining or reproducing the printing result {"value":"�"} and identifying a concrete resolution.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, kafka
- Domain
- distributed-systems
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100