when trying to stream Avro data with Kafka Streams, I came across this error:
Exception in thread "StreamThread-1" org.apache.kafka.common.errors.SerializationException: Error deserializing Avro message for id -1
Caused by: org.apache.kafka.common.errors.SerializationException: Unknown magic byte!
Even though I found several older threads about it in the mailing list, none of the solutions stated there fixed the problem. So hopefully, I can find a solution here.
My setup looks as follows:
StreamsConfig.KEY_SERDE_CLASS_CONFIG, Serdes.String.getClass.getName
StreamsConfig.VALUE_SERDE_CLASS_CONFIG, classOf[GenericAvroSerde]
AbstractKafkaAvroSerDeConfig.SCHEMA_REGISTRY_URL_CONFIG, localhost:8081)
I already tried setting the KEY_SERDE
to the same as the VALUE_SERDE
, but even though this was "marked" as a solution in the Mailing list, it did not work in my case.
I'm generating GenericData.Record
with my Schema as follows:
val record = new GenericData.Record(schema)
...
record.put(field, value)
When I start the debug mode and check the generated record, everything looks fine, there is data in the record and the mapping is correct.
I stream the KStream like this (I used branch before):
splitTopics.get(0).to(s"${destTopic}_Testing")
I'm using GenericData.Record
for the records. Might this be a problem in combination with the GenericAvroSerde
?