In a decoupled architecture (e.g., Kafka, gRPC), the "contract" between services is the schema. A Schema Registry acts as the single source of truth and the gatekeeper for evolution, ensuring that a producer cannot ship a change that crashes its consumers.
When updating a schema, you must select a compatibility mode. This decision dictates whether you update consumers or producers first.
| Mode | Who can read what? | Update Order |
|---|---|---|
| Backward | New consumer can read old data. | Consumers first. |
| Forward | Old consumer can read new data. | Producers first. |
| Full | Both are true. | Any order. |
| None | No checks. | Dangerous; requires coordinated downtime. |
int to string is not compatible).Protobuf relies on integer tags, not field names. Renaming user_name to username is fine; changing tag 1 to tag 2 is a catastrophic failure.
message User {
// Field 1 was removed in v2.0. DO NOT REUSE THE ID.
reserved 1;
reserved "old_field_name";
string username = 2; // Use ID 2
int32 age = 3;
}
Schema v2.v2 against v1 using the configured compatibility rule (e.g., BACKWARD).v2 from the registry by ID when it encounters a message it doesn't recognize.If you MUST make a breaking change:
/v2/).