liveBook · Manning

Subject

As explained in Kafka Streams in Action, Second Edition

A subject name is a Schema Registry identifier that groups schema versions governing a particular stream key or value.

A subject is the Schema Registry name that scopes schema versions for a Kafka topic’s key or value. For example, avro-avengers-value governs the schemas used by values in the avro-avengers topic. Schema Registry assigns each registered schema a unique ID, while the subject organizes its version history. section 3.2.5

Choose a subject naming strategy according to how records are organized:

  • TopicNameStrategy uses <topic>-key or <topic>-value, keeping one data type and schema scope per topic. Different topics can use different schemas for the same record type. section 3.3.1
  • RecordNameStrategy uses the fully qualified Java class name, allowing related record types in one topic while checking compatibility for the same record name across topics. section 3.3.2

Register and inspect a subject

Register a value schema by posting to /subjects/avro-avengers-value/versions. The response returns a schema ID such as 1. Query /subjects to list subject names, /subjects/avro-avengers-value/versions to list versions, and /subjects/avro-avengers-value/versions/latest to retrieve the current schema. section 3.2.5

Listing 3.5 Registering a schema on the command line
jq '. | {schema: tojson}' src/main/avro/avenger.avsc | \   #1
curl -s -X
   POST http://localhost:8081/subjects/avro-avengers-value/versions\    #2
   -H "Content-Type: application/vnd.schemaregistry.v1+json" \     #3
   -d @-  \           #4
   | jq    #5

Shows the REST registration command and the subject path used for an Avro value schema. section 3.2.5

How Kafka Streams in Action, Second Edition covers it

How deep it goes
Explains subject naming, registration, identifiers, version queries, and strategy trade-offs without detailing compatibility algorithms.
Examples
Uses avro-avengers-value, REST registration commands, schema ID 1, and AvengerAvro strategy configurations.
What it assumes
Assumes basic Kafka topics and serialized keys or values, while demonstrating subject registration and lookup from concrete commands.
What you can do after
Operate/configure Schema Registry subjects through REST endpoints and select producer and consumer naming strategies.
How it connects
Connects Kafka topics, schema versions, compatibility checks, Avro serialization, Protobuf, and JSON Schema.

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 Streams in Action, Second Edition. The section links point to the parts of the book it draws on.