liveBook · Manning

Data contract

As explained in Troubleshooting Java, Second Edition

A data contract is an agreed schema and interpretation for data exchanged between software components or services.

A data contract is an agreed schema and interpretation for data exchanged between software components or services. It defines how structured data is serialized, deserialized, and evolved without silently breaking consumers. section 12.2

Contract failures can hide behind dropped fields, default values, or delayed deserialization errors. Investigate the producer’s schema, the consumer’s model, field optionality, enum changes, and Java serialization identifiers before blaming the transport. section 12.2

Reliable contract evolution depends on:

  • Maintaining forward and backward compatibility so services can evolve independently. section 12.2
  • Treating Protobuf schemas and generated classes as shared service boundaries rather than local implementation details. section 12.2
  • Checking whether added fields, renamed enums, or changed models are understood consistently by every participant. section 12.2
message Order {
  int64 id = 1;
  string customer_id = 2;
  repeated string items = 3;
  optional string notes = 4;
}

Use the schema to inspect field numbers, types, repetition, and optionality before changing a message exchanged between services. section 12.2

How Troubleshooting Java, Second Edition covers it

How deep it goes
Explains mismatch symptoms, schema evolution, and compatibility concerns, but does not provide a complete compatibility procedure.
Examples
Uses added JSON fields, renamed Protobuf enums, changed Java classes, and a Protobuf Order message with optional notes.
What it assumes
Assumes software components exchange serialized structured data and introduces Protobuf as a schema-based alternative to JSON or XML.
What you can do after
Diagnose dropped data, default values, and deserialization errors by comparing schemas, models, optionality, and version identifiers.
How it connects
Connects serialization, versioning, JSON, Protobuf, gRPC, Java deserialization, and forward and backward compatibility.

Also explained in

Compare how 4 books explain data contract →

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.