تطور المخطط وأنماط التوافق
تعلّم كيف يفرض Confluent Schema Registry التوافق مع تغيّر المخططات، وكيف تختار بأمان التوافق العكسي أو الأمامي أو الكامل.
تطور المخطط وأنماط التوافق درس مجاني في Apache Kafka & Stream Processing Fundamentals على CoddyKit. هذا هو الدرس 4 من أصل 4. يمكنك قراءة الدرس كاملاً أدناه مجاناً — ثم تمرن عليه مباشرة في المتصفح باستخدام محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7. هذا الدرس جزء من مسار التعلم في Apache Kafka & Stream Processing Fundamentals، وتقدمك يتزامن عبر الويب وتطبيق CoddyKit. تتضمن دورة Apache Kafka & Stream Processing Fundamentals 4 دروس في المجموع.
بعض أجزاء هذا الدرس لم تُترجم بعد وتظهر باللغة الإنجليزية.
Why Schemas Evolve
Data contracts change over time — you add fields, deprecate others, rename things. Schema evolution is the discipline of changing schemas without breaking existing producers and consumers.
The Compatibility Problem
Producers and consumers often deploy at different times. A new producer might emit a v2 schema while old consumers still expect v1.
Without rules, that mismatch causes deserialization failures in production.
Backward Compatibility
Backward: new schema can read data written with the old schema.
- Safe changes: delete a field, add a field with a default.
- Upgrade consumers first.
Forward Compatibility
Forward: old schema can read data written with the new schema.
- Safe changes: add a field, delete a field that had a default.
- Upgrade producers first.
Full Compatibility
Full requires both backward and forward compatibility at once.
- Only changes safe in both directions are allowed (add/remove fields with defaults).
- Producers and consumers can be upgraded in any order.
Transitive Variants
Each mode has a transitive version (BACKWARD_TRANSITIVE, etc.).
Non-transitive checks only against the latest schema; transitive checks against all prior versions — stronger guarantees, more constraints.
Setting Compatibility
Compatibility is configured per subject (or globally) via the Schema Registry REST API.
curl -X PUT \
http://localhost:8081/config/orders-value \
-H 'Content-Type: application/vnd.schemaregistry.v1+json' \
-d '{"compatibility": "BACKWARD"}'A Backward-Safe Avro Change
Adding a field with a default keeps old data readable under BACKWARD mode.
{
"type": "record",
"name": "Order",
"fields": [
{"name": "id", "type": "string"},
{"name": "amount", "type": "double"},
{"name": "currency", "type": "string", "default": "USD"}
]
}Testing Before You Register
The registry can check a candidate schema against the current one before you commit it.
curl -X POST \
http://localhost:8081/compatibility/subjects/orders-value/versions/latest \
-H 'Content-Type: application/vnd.schemaregistry.v1+json' \
-d '{"schema": "...escaped avro..."}'Breaking Changes
Changes that almost always break compatibility:
- Renaming a field (treated as delete + add).
- Changing a field's type incompatibly.
- Adding a required field with no default.
For these, create a new subject/topic version instead.
Choosing a Mode
Rules of thumb:
- BACKWARD (default) when you upgrade consumers first.
- FORWARD when producers lead.
- FULL for independently deployed teams.
- Use transitive variants for long-lived, replayable topics.
Quick Check
Test your understanding of compatibility modes.
Recap
You learned schema evolution and compatibility modes.
- BACKWARD: new reads old, upgrade consumers first.
- FORWARD: old reads new, upgrade producers first.
- FULL: both, any order.
- Transitive variants check all prior versions; renames and required no-default fields break compatibility.
الأسئلة الشائعة
هل درس «تطور المخطط وأنماط التوافق» مجاني؟
نعم — نص درس «تطور المخطط وأنماط التوافق» كامل متاح مجاناً هنا على الويب. لتمرينه بشكل تفاعلي (محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7) وفتح باقي دورة Apache Kafka & Stream Processing Fundamentals، انتقل إلى CoddyKit PRO. تتضمن دورة Apache Kafka & Stream Processing Fundamentals 4 دروس في المجموع.
ماذا ستتعلم في «تطور المخطط وأنماط التوافق»؟
تعلّم كيف يفرض Confluent Schema Registry التوافق مع تغيّر المخططات، وكيف تختار بأمان التوافق العكسي أو الأمامي أو الكامل. تتمرن على Apache Kafka & Stream Processing Fundamentals مع أكواد عملية تشغلها مباشرة في المتصفح، ومدرس ذكاء اصطناعي متاح 24/7 يجيب على أسئلتك أثناء عملك.
هل أحتاج إلى خبرة سابقة لأبدأ Apache Kafka & Stream Processing Fundamentals؟
لا تُشترط خبرة سابقة. Apache Kafka & Stream Processing Fundamentals على CoddyKit منظم للمبتدئين حتى المتقدمين، لذا يمكنك البدء من هنا أو من البداية والتقدم بسرعتك الخاصة. هذا هو الدرس 4 من أصل 4.
كم من الوقت يستغرق درس «تطور المخطط وأنماط التوافق»؟
معظم دروس CoddyKit تستغرق حوالي 5–10 دقائق. كل منها موجز وتفاعلي، لذا تحرز تقدماً مستمراً وتستأنف من حيث توقفت عبر الويب والتطبيق.
هل يمكنني كتابة وتشغيل أكواد في درس Apache Kafka & Stream Processing Fundamentals هذا؟
نعم. كل درس في Apache Kafka & Stream Processing Fundamentals يتضمن محرر أكواد مدمج، لذا تكتب وتشغل أكواداً حقيقية مباشرة في متصفحك وتحصل على تعليقات فورية من الذكاء الاصطناعي — بدون إعداد محلي.
جميع الدروس في هذه الدورة
- لماذا نحتاج إلى إدارة المخططات؟
- مخططات Avro وProtobuf
- دمج Schema Registry مع Kafka
- تطور المخطط وأنماط التوافق