Kafka: Schema evolution needs a compatibility rule

BACKWARD compatibility lets new consumers read old data - the usual default with a schema registry.

Code
// v1
{"orderId": 42, "total": 149.5}

// v2 - BACKWARD compatible: new field has a default
{"orderId": 42, "total": 149.5, "currency": "INR"}

// NOT compatible - removing a required field, or renaming one
{"id": 42, "total": 149.5}
Output
BACKWARD: new consumer, old data  (add optional fields, remove optional ones)
FORWARD:  old consumer, new data
FULL:     both
Advertisement

Run this yourself in the Online Java Compiler, spin up a live REST API in the API Sandbox, or practise with Java interview questions.

Published 2026-08-11