The code widget below demonstrates a consumer reading Kafka messages using Avro serialization. We haven’t delved into the workings of Avro, but in general, we can create messages of type GenericRecord or generate Java classes from our schema using Avro tools. The code in the widget uses the GenericRecord approach which loses type-safety and requires casts when the message is read on the consumer’s end.