liveBook · Manning

Forward compatibility

As explained in Troubleshooting Java, Second Edition

Forward compatibility is the ability of an older consumer or implementation to tolerate data produced according to a newer schema.

Forward compatibility lets an older consumer tolerate data produced with a newer schema. It protects service communication as schemas evolve. section 12.2

Use schema compatibility checks to investigate changes before they reach consumers:

  • Adding an optional field is usually safe because older clients can ignore it. section 12.2
  • Removing or renaming a field, or changing its type, usually creates a breaking change. section 12.2
  • Compare current and previous schemas in CI with Buf for Protobuf or avro-tools for Avro. section 12.2

A safe schema extension

Adding optional string notes to an existing Order message can preserve compatibility with older consumers. A CI check comparing schema versions can flag unsafe alternatives before deployment. section 12.2

message Order {
  int64 id = 1;
  string customer_id = 2;
  repeated string items = 3;
  optional string notes = 4;
}

Inspect the Order message to see how an optional field can extend an existing schema. section 12.2

How Troubleshooting Java, Second Edition covers it

How deep it goes
Defines compatibility through field changes and outlines CI and runtime validation, without detailing compatibility algorithms.
Examples
Uses optional fields, renamed or removed fields, type changes, and an Order message as concrete examples.
What it assumes
Assumes familiarity with schemas, consumers, producers, and service messages.
What you can do after
Evaluate schema changes with Buf or avro-tools and identify likely breaking changes before deployment.
How it connects
Connects schema evolution with serialization, backward compatibility, Protobuf, Avro, and schema registries.

Also explained in

Compare how 5 books explain forward compatibility →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Troubleshooting Java, Second Edition. The section links point to the parts of the book it draws on.