0Pricing
Apache Kafka & Stream Processing Fundamentals · Lezione

Evoluzione dello schema e modalità di compatibilità

Scopra come Confluent Schema Registry imponga la compatibilità durante le modifiche agli schemi e come scegliere in sicurezza la compatibilità backward, forward o full.

Evoluzione dello schema e modalità di compatibilità è una lezione Apache Kafka & Stream Processing Fundamentals gratuita su CoddyKit. Questa è la lezione 4 di 4. Puoi leggere la lezione completa qui gratuitamente — poi esercitati direttamente nel browser con un editor di codice integrato e un tutor IA disponibile 24/7. Fa parte del percorso di apprendimento Apache Kafka & Stream Processing Fundamentals, e i tuoi progressi si sincronizzano tra il web e l'app CoddyKit. Il corso Apache Kafka & Stream Processing Fundamentals include 4 lezioni in totale.

Parti di questa lezione non sono ancora state tradotte e vengono mostrate in inglese.

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.

Domande Frequenti

La lezione «Evoluzione dello schema e modalità di compatibilità» è gratuita?

Sì — il testo completo di «Evoluzione dello schema e modalità di compatibilità» è gratuito qui sul web. Per esercitarvi in modo interattivo (un editor di codice integrato e un tutor IA 24/7) e sbloccare il resto del corso Apache Kafka & Stream Processing Fundamentals, passa a CoddyKit PRO. Il corso Apache Kafka & Stream Processing Fundamentals include 4 lezioni in totale.

Cosa imparerò in «Evoluzione dello schema e modalità di compatibilità»?

Scopra come Confluent Schema Registry imponga la compatibilità durante le modifiche agli schemi e come scegliere in sicurezza la compatibilità backward, forward o full. Eserciti Apache Kafka & Stream Processing Fundamentals con codice pratico che esegui direttamente nel browser, e un tutor IA 24/7 risponde alle tue domande mentre lavori sulla lezione.

Ho bisogno di esperienza per iniziare Apache Kafka & Stream Processing Fundamentals?

Non è richiesta alcuna esperienza precedente. Apache Kafka & Stream Processing Fundamentals su CoddyKit è strutturato per principianti e studenti avanzati, quindi puoi iniziare da qui o dall'inizio e procedere al tuo ritmo. Questa è la lezione 4 di 4.

Quanto tempo richiede la lezione «Evoluzione dello schema e modalità di compatibilità»?

La maggior parte delle lezioni CoddyKit richiede circa 5–10 minuti. Ogni lezione è breve e interattiva, quindi fai progressi costanti e riprendi esattamente da dove hai lasciato su web e app.

Posso scrivere ed eseguire codice in questa lezione Apache Kafka & Stream Processing Fundamentals?

Sì. Ogni lezione Apache Kafka & Stream Processing Fundamentals include un editor di codice integrato, quindi scrivi ed esegui codice reale direttamente nel tuo browser e ricevi feedback istantaneo dall'IA — nessuna configurazione locale necessaria.

Tutte le lezioni di questo corso

  1. Perché gestire gli schemi?
  2. Schemi Avro e Protobuf
  3. Integrazione di Schema Registry con Kafka
  4. Evoluzione dello schema e modalità di compatibilità
← Torna a Apache Kafka & Stream Processing Fundamentals