liveBook · Manning

Subject

As explained in Kafka for Architects

A subject is a Schema Registry entity that groups versions of a data schema according to an event type, topic, or both.

A subject groups schema versions for an event domain while separating that domain model from the Kafka topic arrangement. Organizations can map one event type to one topic or group related event types in a shared topic. section 6.4.3

When an event structure changes, the Schema Registry creates a new subject version. Compatibility rules belong to the subject and determine whether the new schema can be registered. section 6.4.3 section 6.4.4

Subject design makes the event-to-topic relationship an explicit architectural choice:

  • TopicNameStrategy associates schema evolution with a specific Kafka topic, such as CLIENTS, keeping compatible schema versions together. section 6.4.3
  • Backward compatibility lets upgraded consumers read earlier messages, permitting removed fields and newly added fields with defaults. section 6.4.4
  • Rejected incompatible registrations protect consumers, although coordination becomes harder when many independent teams consume the subject. section 6.4.4

Client events on CLIENTS

An Avro ClientEvent carries an event identifier, event type, timestamp, client identifier, and client name. Published to CLIENTS with TopicNameStrategy, its schema versions are grouped under the topic-associated subject. section 6.4.3

Listing 6.10 An example of the client event in Avro format
{
  "type": "record",
  "name": "ClientEvent",
  "namespace": "com.example",
  "fields": [
    {
      "name": "eventId",
      "type": "string",
      "doc": "Unique identifier for the event"
    },
    {
      "name": "eventType",
      "type": "string",
      "doc": "Type of event (e.g., 'ClientCreated', 'ClientUpdated')"
    },
    {
      "name": "timestamp",
      "type": "long",
      "logicalType": "timestamp-millis",
      "doc": "Event timestamp in milliseconds"
    },
    {
      "name": "clientId",
      "type": "string",
      "doc": "Unique identifier for the client"
    },
    {
      "name": "clientName",
      "type": "string",
      "doc": "Name of the client"
    }
  ]
}

Inspect the ClientEvent schema to see the concrete event structure governed by a subject. section 6.4.3

How Kafka for Architects covers it

How deep it goes
Explains mapping, version evolution, and compatibility, but does not detail all available subject strategies.
Examples
Uses a ClientEvent Avro schema on CLIENTS and ClientProfile V1/V2 compatibility scenarios.
What it assumes
Assumes event schemas and Kafka topics, then defines how Schema Registry subjects organize their evolution.
What you can do after
Evaluate subject-to-topic strategies and govern schema evolution with compatibility modes.
How it connects
Connects event types, Kafka topics, Schema Registry, schema versions, and compatibility rules.

Also explained in

Compare how 2 books explain subject →

Related concepts

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