A deserializer converts Kafka record bytes into an object a consumer can use. The consumer passes a byte array to deserialize and receives the expected object type. Producers and consumers remain decoupled from the conversion classes; configuration supplies the implementation. Because they evolve independently, the producer’s serialized object type and the consumer’s deserialized type form an implicit event contract. section 3.1
Figure 3.1 The conversion of objects to bytes and bytes to objects happens at the client level.
Follow the conversion boundary: objects become bytes before reaching a Kafka topic, then bytes become objects after a consumer reads them. section 3.1
A Schema Registry–aware deserializer adds schema discovery to that conversion. After a consumer reads record bytes, it retrieves the needed schema over HTTP when absent from its local cache, then deserializes according to that schema. Registry-backed serializers and deserializers are available for Avro, Protobuf, and JSON Schema, helping standardize data handling and preserve schema validation. section 3.2.1 section 3.7
Configure an Avro consumer
Configure the consumer value deserializer as KafkaAvroDeserializer and provide the Schema Registry URL. Set SPECIFIC_AVRO_READER_CONFIG to true to receive generated specific Avro records and call typed accessors such as getName(); leave it false to receive a GenericRecord and access fields by name after checking that they exist. section 3.2.9
Schema Registry is optional. A custom class can implement org.apache.kafka.common.serialization.Deserializer, whose required method is deserialize; configure and close are default methods that may be overridden. A JSON-based implementation can pass the bytes and target object class to Jackson ObjectMapper.readValue, returning the reconstructed value or wrapping an IOException in SerializationException. section 3.8 section 3.8
Configure serialization classes on KafkaProducer or KafkaConsumer rather than invoking them directly. In Kafka Streams, use a Serde—a paired serializer and deserializer—because the embedded producer and consumer are not directly accessible. section 3.7
