0Pricing
Apache Kafka & Stream Processing Fundamentals · บทเรียน

วิวัฒนาการของสคีมาและโหมดความเข้ากันได้

เรียนรู้ว่า Confluent Schema Registry บังคับใช้ความเข้ากันได้เมื่อสคีมาเปลี่ยนแปลงอย่างไร และวิธีเลือกความเข้ากันได้แบบย้อนหลัง แบบไปข้างหน้า หรือแบบเต็มอย่างปลอดภัย

วิวัฒนาการของสคีมาและโหมดความเข้ากันได้ เป็นบทเรียน Apache Kafka & Stream Processing Fundamentals ฟรีบน CoddyKit นี่คือบทเรียนที่ 4 จากทั้งหมด 4 บทเรียน คุณสามารถอ่านบทเรียนทั้งหมดด้านล่างฟรี — จากนั้นลองปฏิบัติด้วยตัวคุณเองในเบราว์เซอร์พร้อมตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 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.

คำถามที่พบบ่อย

บทเรียน “วิวัฒนาการของสคีมาและโหมดความเข้ากันได้” ฟรีหรือไม่

ใช่ — ข้อความเต็มของ “วิวัฒนาการของสคีมาและโหมดความเข้ากันได้” ฟรีให้อ่านที่นี่บนเว็บ เพื่อปฏิบัติแบบโต้ตอบ (ตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7) และปลดล็อคส่วนที่เหลือของคอร์ส Apache Kafka & Stream Processing Fundamentals ให้อัปเกรดเป็น CoddyKit PRO คอร์ส Apache Kafka & Stream Processing Fundamentals มีบทเรียนทั้งหมด 4 บทเรียน

คุณจะเรียนรู้อะไรในบทเรียน “วิวัฒนาการของสคีมาและโหมดความเข้ากันได้”

เรียนรู้ว่า Confluent Schema Registry บังคับใช้ความเข้ากันได้เมื่อสคีมาเปลี่ยนแปลงอย่างไร และวิธีเลือกความเข้ากันได้แบบย้อนหลัง แบบไปข้างหน้า หรือแบบเต็มอย่างปลอดภัย คุณปฏิบัติ Apache Kafka & Stream Processing Fundamentals ด้วยโค้ดที่ใช้งานได้จริงที่คุณเรียกใช้โดยตรงในเบราว์เซอร์ และติวเตอร์ AI ตลอด 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 ทุกบทมีตัวแก้ไขโค้ดในตัว คุณจึงเขียนและรันโค้ดจริงได้เลยในเบราว์เซอร์ และได้รับข้อเสนอแนะจาก AI ในทันที — ไม่ต้องติดตั้งในเครื่องของคุณ

บทเรียนทั้งหมดในหลักสูตรนี้

  1. เหตุใดจึงต้องจัดการสคีมา
  2. สคีมา Avro และ Protobuf
  3. การผสานรวม Schema Registry กับ Kafka
  4. วิวัฒนาการของสคีมาและโหมดความเข้ากันได้
← กลับไปที่ Apache Kafka & Stream Processing Fundamentals