liveBook · Manning

Subject name strategy

As explained in Kafka Streams in Action, Second Edition

A subject name strategy is a rule that determines how Schema Registry subject names are derived and therefore where compatibility is checked.

A subject name strategy determines how Schema Registry derives subjects and therefore where it checks schema compatibility. Treat the strategy as a function of the topic name and record schema. section 3.3 section 3.3.3

Choose among three scopes:

  • TopicNameStrategy uses the topic name and ignores the record schema; it may allow multiple types in a topic and supports different object versions across topics. section 3.3.3
  • RecordNameStrategy uses the fully qualified record name, so schemas with the same record name are checked together across every topic using that subject. All those topics must use the same schema. section 3.3.2
  • TopicRecordNameStrategy uses both topic and record name, allowing multiple event types in a topic and different schema versions for the same type across topics. section 3.3.3

Configure a record-scoped subject

For an Avro AvengerAvro record, configure both producer and consumer value serializers or deserializers with RecordNameStrategy. Configure key strategies only when keys use schemas, and remember that key and value strategies may differ. section 3.3.2

Figure 3.7 RecordNameStrategy enforces having the same schema for a domain object across different topics.
figure

Use the diagram to see how RecordNameStrategy enforces one schema for a domain object across different topics. section 3.3.2

How Kafka Streams in Action, Second Edition covers it

How deep it goes
Defines three naming functions, compares their topic and record scopes, and demonstrates producer and consumer configuration.
Examples
Uses Avro domain objects, IoT event types, CustomerPurchaseEvent versions, and Java producer and consumer configurations.
What you can do after
Operate/configure Schema Registry clients with a strategy matching topic co-location and cross-topic versioning requirements.
How it connects
Connects schema evolution, Schema Registry subjects, compatibility modes, serializers, deserializers, topics, and schema references.

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.