Why a registry exists
In a streaming system many producers and consumers share topics over years. If a producer changes a message shape carelessly, consumers break. A schema registry is a central service that stores versioned schemas and enforces compatibility rules before a new version is allowed.
How messages reference schemas
- A producer registers its schema and the registry returns a schema id.
- The message carries the id, not the full schema, so payloads stay small.
- The consumer fetches the schema by id to decode the message.
Compatibility modes
- Backward: new schema can read data written by old schemas, so you can upgrade consumers first.
- Forward: old schema can read data written by new schemas, so you can upgrade producers first.
- Full: both directions hold, the safest and most restrictive.
Safe evolution rules
- Add optional fields with defaults, so old readers ignore them and new readers fill a default for old data.
- Do not remove or rename required fields, which breaks readers expecting them.
- Never change a field type incompatibly, since decoding will fail.
Key idea
A schema registry versions message schemas and enforces backward or forward compatibility, so adding optional defaulted fields lets producers and consumers evolve independently without breaking each other.