liveBook · Manning

Implicit contract

As explained in Kafka Streams in Action, Second Edition

An implicit contract is an unstated agreement about the data structure and representation that communicating software components must share.

An implicit contract is an unstated agreement about the structure and representation of data exchanged by otherwise independent software components. In event streaming, a producer serializes an object for a topic, while a consumer expects to deserialize the same object type. section 3.1

Figure 3.1 The conversion of objects to bytes and bytes to objects happens at the client level.
figure

Use the conversion diagram to separate client-side object serialization from broker-level message transport and consumer-side deserialization. section 3.1

The contract becomes operational through three related concerns:

  • A producer and consumer can remain agnostic of each other, but both must agree on the event domain object's representation. section 3.1
  • Changing a field from java.util.Date to long can break downstream consumers when the expected field type changes unexpectedly. section 6.4.5
  • Schemas and Schema Registry make the agreement explicit enough to coordinate changes and perform compatibility checks. section 6.4.5

Schema-aware Kafka Streams application

Create a provided Serde, configure it with the Schema Registry URL, and use it in the Kafka Streams application. Kafka Streams follows the same schema-evolution and compatibility rules because it contains producer and consumer clients. section 6.4.5

How Kafka Streams in Action, Second Edition covers it

How deep it goes
Defines the agreement, demonstrates a breaking field-type change, and defers enforcement details to schemas and compatibility checks.
Examples
Uses producer-consumer object exchange, a Date-to-long field change, and Schema Registry-aware Kafka Streams Serdes.
What it assumes
Assumes producer, consumer, serializer, and deserializer roles while establishing their shared object-type expectation.
What you can do after
Apply it via Schema Registry-aware Serdes to coordinate event representations and detect incompatible schema evolution.
How it connects
Connects domain objects with serialization, deserialization, schemas, Schema Registry, Serdes, and Kafka Streams.

Related concepts

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