liveBook · Manning

Schema registry

As explained in Apache Kafka in Action

A schema registry is a service that stores, versions, and provides access to schemas governing data formats.

A schema registry is a central service for storing and versioning schemas used by Kafka producers and consumers. It checks whether schema changes are compatible and provides schema information to clients. Registries support Avro, JSON, and Protobuf schemas. section 13.1.3 section 13.1.4

With Avro, storing the schema in the registry and putting only its ID in each Kafka message avoids repeating the schema with every payload. This keeps messages smaller while retaining a link to the schema version. Because Kafka handles byte arrays, schema checks happen on the client side, not in Kafka itself. section 13.1.4 section 13.1.3

{
  "type": "record",
  "name": "Product",
  "namespace": "com.example.supermarket",
  "fields": [
    {"name": "id", "type": "string"},
    {"name": "name", "type": "string"},
    {"name": "price", "type": "float"},
    {"name": "stock", "type": "int"},
    {"name": "origin", "type": ["null", "string"], "default": null}
  ]
}

This Product record illustrates the kind of Avro schema a registry can store and version. section 13.1.4

Plan for operational trade-offs:

  • A registry adds a component whose unavailability can affect producers and consumers; multi-cluster setups need careful planning. section 13.1.3
  • Schema IDs have no semantic meaning, and manually exporting and importing schemas can change IDs, complicating recovery and migration. section 13.1.3

How Apache Kafka in Action covers it

How deep it goes
Explains registry functions, Avro schema-ID messaging, and operational risks, but leaves client-side enforcement mitigation unspecified.
Examples
Uses a Product Avro record and contrasts sending its full schema with referencing it by ID.
What you can do after
Apply schema IDs to Kafka messages while keeping schemas centrally stored and compatibility-checked.
How it connects
Connects Kafka, Avro, JSON, Protobuf, schema versioning, and compatibility checks.

Also explained in

Compare how 3 books explain schema registry →

Related concepts

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