1
votes

I am new to Confluent Schema Registry and I am trying to understand the core concepts first. I am a little fuzzy on TopicRecordNameStrategy:

TopicRecordNameStrategy: Derives the subject name from topic and record name, as a way to group logically related events that may have different data structures under a subject.

The non-default naming strategies (RecordNameStrategy and TopicRecordNameStrategy) support schema management for use cases where grouping by topic isn’t optimal, for example a single topic can have records that use multiple schemas.

Those are the quotes from the CSR documentation.

Say, I have a topic X, through which I push message type A and message type B (those message types represent completely different classes).

I have the following 3 questions:

  1. How many subjects will I get as a result of this, considering that I am employing TopicRecordNameStrategy? Is it gonna be a single subject or 2?
  2. How is the name of the subject formed?
  3. Since each message can have key and value schemas set, how does it impact the number of subjects?
1

1 Answers

2
votes

Good overview on multiple event types in the same Kafka topic.

There are two separate configuration options one for key and one for value: key.subject.name.strategy (which defines how to construct the subject name for message keys), and value.subject.name.strategy (how to construct the subject name for message values).

For value TopicRecordNameStrategy: The subject name is <topic>-<type>-value, where <topic> is the Kafka topic name, and <type> is the fully-qualified name of the Avro record type of the message.

In your case, there will be 2 subjects for value: <topic X>-<type A>-value and <topic X>-<type B>-value. For keys, with default TopicNameStrategy, you can have one <topic X>-<key>. Confluent docs on how the naming strategies work.