Schema Registry & Avro
IntermediateSchema Registry centralises Avro/JSON/Protobuf schemas so producers and consumers share a contract. It prevents breaking changes from silently corrupting downstream consumers.
Overview
Producers register schemas and embed a schema ID in each message; consumers fetch the schema by ID and deserialise. Compatibility modes (BACKWARD, FORWARD, FULL) control which schema changes are allowed.
Avro + Schema Registry in Spring Boot
Configure schema.registry.url on producer and consumer. Use KafkaAvroSerializer / KafkaAvroDeserializer.
# application.properties
spring.kafka.producer.value-serializer=io.confluent.kafka.serializers.KafkaAvroSerializer
spring.kafka.producer.properties.schema.registry.url=http://schema-registry:8081
spring.kafka.consumer.value-deserializer=io.confluent.kafka.serializers.KafkaAvroDeserializer
spring.kafka.consumer.properties.schema.registry.url=http://schema-registry:8081
spring.kafka.consumer.properties.specific.avro.reader=trueSchema Compatibility Modes
BACKWARD: new schema reads old messages. FORWARD: old schema reads new messages. FULL: both directions. NONE: no checks.
curl -X PUT http://schema-registry:8081/config/orders-value \
-H "Content-Type: application/vnd.schemaregistry.v1+json" \
-d '{"compatibility": "BACKWARD"}'Key Points to Remember
- 1Schema Registry stores schemas centrally; each message embeds only a 5-byte schema ID
- 2BACKWARD: consumers with old schema can still read new messages
- 3Adding a field with a default is BACKWARD compatible; removing a required field is not
- 4Subject naming: {topic}-key and {topic}-value
- 5Avro is compact binary; Protobuf has better language support; JSON is human-readable
Interview Questions
Sign in to ask AriaWhat problem does Schema Registry solve in a Kafka-based system?
What is BACKWARD schema compatibility and which type of schema change breaks it?
How does Schema Registry avoid embedding the full Avro schema in every message?
What happens if a consumer has an older schema version and receives a message produced with a newer schema?
When would you choose Protobuf over Avro for Kafka messages?
Ask Aria about Schema Registry & Avro
Your personal AI tutor — ask anything about this concept
Revision Status
Personal Notes
Sign in to save personal notes for this topic.
Discussion
Sign in to join the discussion.