SpringSpring Kafka Configuration
How do you configure Spring Kafka for Avro with Confluent Schema Registry?
Reference answer
Spring does not ship the Avro serializers; they come from Confluent's kafka-avro-serializer library, which you add as a dependency. Spring Boot exposes serializer classes directly and passes any other client setting through the generic properties map (spring.kafka.producer.properties.* and spring.kafka.consumer.properties.*). Producer: spring.kafka.producer.value-serializer=io.confluent.kafka.serializers.KafkaAvroSerializer and spring.kafka.producer.properties.schema.registry.url=http://schema-registry:8081. Consumer: spring.kafka.consumer.value-deserializer=io.confluent.kafka.serializers.KafkaAvroDeserializer, spring.kafka.consumer.properties.schema.registry.url=http://schema-registry:8081 and spring.kafka.consumer.properties.specific.avro.reader=true. specific.avro.reader defaults to false, in which case the consumer returns GenericRecord; true returns your generated classes (SpecificRecord). Generate the Java classes from .avsc files with a build plugin such as avro-maven-plugin. On send, the serializer registers the schema in the registry under a subject such as <topic>-value, and each message carries a magic byte and a schema ID rather than the schema itself.
Expected key concepts: KafkaAvroSerializer, KafkaAvroDeserializer, schema.registry.url, specific.avro.reader, avro-maven-plugin, Confluent, schema ID, spring.kafka.producer.properties, GenericRecord, SpecificRecord, subject
How did that feel?
Your own verdict, not the score. It shows up next to this question in the list, so you can come back to the shaky ones.