0Pricing
Apache Kafka & Stream Processing Fundamentals · Lekcja

Ewolucja schematu i tryby zgodności

Nauczą się Państwo, jak Confluent Schema Registry egzekwuje zgodność podczas zmian schematów oraz jak bezpiecznie wybierać zgodność wsteczną, przyszłą lub pełną.

Ewolucja schematu i tryby zgodności to bezpłatna lekcja Apache Kafka & Stream Processing Fundamentals na CoddyKit. To lekcja 4 z 4. Możesz przeczytać całą lekcję poniżej za darmo — a potem ćwiczyć ją interaktywnie w przeglądarce z wbudowanym edytorem kodu i tutorem AI dostępnym 24/7. To część ścieżki edukacyjnej Apache Kafka & Stream Processing Fundamentals, a Twój postęp synchronizuje się między webem a aplikacją CoddyKit. Kurs Apache Kafka & Stream Processing Fundamentals zawiera 4 lekcji w sumie.

Części tej lekcji nie zostały jeszcze przetłumaczone i są wyświetlane po angielsku.

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.

Często zadawane pytania

Czy lekcja „Ewolucja schematu i tryby zgodności” jest bezpłatna?

Tak — pełny tekst „Ewolucja schematu i tryby zgodności” jest dostępny za darmo tutaj w sieci. Aby ćwiczyć ją interaktywnie (wbudowany edytor kodu i tutor AI dostępny 24/7) i odblokować resztę kursu Apache Kafka & Stream Processing Fundamentals, przejdź na CoddyKit PRO. Kurs Apache Kafka & Stream Processing Fundamentals zawiera 4 lekcji w sumie.

Co nauczysz się w „Ewolucja schematu i tryby zgodności”?

Nauczą się Państwo, jak Confluent Schema Registry egzekwuje zgodność podczas zmian schematów oraz jak bezpiecznie wybierać zgodność wsteczną, przyszłą lub pełną. Ćwiczysz Apache Kafka & Stream Processing Fundamentals z praktycznym kodem, który uruchamiasz bezpośrednio w przeglądarce, a tutor AI dostępny 24/7 odpowiada na Twoje pytania podczas pracy nad lekcją.

Czy potrzebuję doświadczenia, aby zacząć Apache Kafka & Stream Processing Fundamentals?

Nie wymagamy żadnego doświadczenia. Apache Kafka & Stream Processing Fundamentals w CoddyKit jest strukturyzowany dla początkujących i zaawansowanych użytkowników, więc możesz zacząć tutaj lub od początku i uczyć się w swoim tempie. To lekcja 4 z 4.

Ile czasu zajmuje lekcja „Ewolucja schematu i tryby zgodności”?

Większość lekcji CoddyKit trwa około 5–10 minut. Każda lekcja to mały, interaktywny krok, dzięki czemu robisz systematyczne postępy i zawsze wracasz dokładnie do tego samego miejsca — na webie i w aplikacji.

Czy mogę pisać i uruchamiać kod w tej lekcji Apache Kafka & Stream Processing Fundamentals?

Tak. Każda lekcja Apache Kafka & Stream Processing Fundamentals zawiera wbudowany edytor kodu, więc piszesz i uruchamiasz prawdziwy kod bezpośrednio w przeglądarce i od razu otrzymujesz sprzężenie zwrotne od AI — bez konfiguracji na komputerze.

Wszystkie lekcje w tym kursie

  1. Dlaczego zarządzanie schematami?
  2. Schematy Avro i Protobuf
  3. Integracja Schema Registry z Kafka
  4. Ewolucja schematu i tryby zgodności
← Powrót do Apache Kafka & Stream Processing Fundamentals