Apache Kafka provides schema management capabilities through the Schema Registry, including various levels of compatibility. In this article, we will discuss three types of transitive compatibility: BACKWARDTRANSITIVE, FORWARDTRANSITIVE, and FULL_TRANSITIVE. Additionally, we will analyze their pros, cons, and provide code examples.
BACKWARD_TRANSITIVE DescriptionBackward transitive compatibility means that a new version of the schema must be compatible with all previous versions. This is useful in systems with a long data lifecycle.
Code Example curl -X PUT \ -H "Content-Type: application/vnd.schemaregistry.v1+json" \ --data '{"compatibility": "BACKWARD_TRANSITIVE"}' \ http://localhost:8081/config/Forward transitive compatibility requires that a new version of the schema be compatible with all future versions. This is useful when consumers are updated asynchronously with producers.
Code Example curl -X PUT \ -H "Content-Type: application/vnd.schemaregistry.v1+json" \ --data '{"compatibility": "FORWARD_TRANSITIVE"}' \ http://localhost:8081/config/\
Full transitive compatibility combines the requirements of backward and forward compatibility. A new schema version must be compatible with both previous and future versions.
Code Example curl -X PUT \ -H "Content-Type: application/vnd.schemaregistry.v1+json" \ --data '{"compatibility": "FULL_TRANSITIVE"}' \ http://localhost:8081/config/| Compatibility Type | Compatibility with Past Versions | Compatibility with Future Versions | Ease of Use | Applicability | |----|----|----|----|----| | BACKWARDTRANSITIVE | ✅ | ❌ | Medium | Long-term data storage | | FORWARDTRANSITIVE | ❌ | ✅ | Medium | Asynchronous updates | | FULL_TRANSITIVE | ✅ | ✅ | Low | Maximum resilience |
\ These compatibility types allow you to configure the system to meet your stability and flexibility requirements. The correct choice depends on your system architecture and use cases.
All Rights Reserved. Copyright , Central Coast Communications, Inc.