Kafka

CCDAK Prep: Choosing Schema Registry Subject Naming Strategies — TopicNameStrategy vs RecordNameStrategy

2026-04-19
NicheeLab Editorial Team

A frequent CCDAK focus on Schema Registry is not the schema itself but rather "which Subject anchors compatibility." How Subjects are named depends on the naming strategy, and it strongly influences schema evolution flexibility, reusability, and operational simplicity.

This article compares the three core strategies (TopicNameStrategy, RecordNameStrategy, TopicRecordNameStrategy) and gives selection guidance and configuration examples for real-world scenarios. It is grounded in official documentation behavior and tuned for both exam prep and field application.

Foundations: The Role of Subjects and Naming Strategies

Schema Registry versions schemas per "Subject" and evaluates compatibility per Subject. Producers register the schema under a Subject during serialization and embed only the Schema ID in messages. Consumers fetch the schema by ID. In other words, the wire format does not contain the Subject name; the Subject is a conceptual boundary for registration and compatibility management.

A naming strategy is the rule that decides this Subject name. The three main options are TopicNameStrategy (default), RecordNameStrategy, and TopicRecordNameStrategy. The choice changes the compatibility scope (limited to one topic, or spanning multiple topics).

  • Compatibility is evaluated per Subject (Backward/Forward/Full, etc.)
  • The default strategy is TopicNameStrategy (<topic>-key / <topic>-value)
  • RecordNameStrategy shares Subjects via the fully qualified record name and encourages reuse across multiple topics
  • Schema IDs are unique across the registry. Since consumers resolve by ID, the Subject is a boundary for compatibility management

Relationship between Producer/Consumer and Subjects

Producer               Schema Registry                 Consumer
    |                          |                            |
    | 1) Serialize(value)      |                            |
    |--> subject resolved -----|                            |
    |    (by strategy)         |                            |
    |                          | 2) Register or lookup      |
    |-------------------------> |    schema under Subject    |
    |                          |    -> returns Schema ID    |
    | 3) Send record (ID+data) |                            |
    |-----------------------------------------------------> |
    |                          | 4) Fetch by Schema ID <----|
    |                          |    (subject not in wire)   |

TopicNameStrategy: The Default Strategy That Scopes Compatibility per Topic

TopicNameStrategy is the safest and default strategy. Subjects split into <topic>-key and <topic>-value, and compatibility is evaluated independently for each topic's key and value. Even when different topics share the same schema, their evolutions do not interfere with each other.

The benefit is that change impact is contained within topic boundaries. The downside is that even when the same schema is shared across topics, Subjects are fragmented, causing duplicate schema registrations and fragmented compatibility policy management.

  • Subject examples: orders-value, orders-key
  • Change impact is confined to a single topic
  • Low reusability for shared schemas (re-registered per topic)
  • A safe default early in operations or in environments with many independent development teams

Configuration example: apply RecordNameStrategy for values and TopicNameStrategy for keys

Properties p = new Properties();
p.put("bootstrap.servers", "localhost:9092");
p.put("key.serializer", "io.confluent.kafka.serializers.KafkaAvroSerializer");
p.put("value.serializer", "io.confluent.kafka.serializers.KafkaAvroSerializer");
p.put("schema.registry.url", "http://localhost:8081");

// 既定はTopicNameStrategyだが、明示も可能
p.put("key.subject.name.strategy", "io.confluent.kafka.serializers.subject.TopicNameStrategy");

// 値だけRecordNameStrategyに切り替える例(混在可)
p.put("value.subject.name.strategy", "io.confluent.kafka.serializers.subject.RecordNameStrategy");

// 本番では自動登録を止め、最新利用へ切り替える選択肢もある
p.put("auto.register.schemas", false);
p.put("use.latest.version", true);

// 確認: 現在のSubject一覧
// curl http://localhost:8081/subjects
// 例: orders-key, orders-value, com.example.OrderCreated などが列挙される

RecordNameStrategy: Reuse Across Topics by Record Name

RecordNameStrategy determines the Subject from Avro's fully qualified name (namespace.name) or the message name in Protobuf/JSON Schema. As a result, even when the same record is used across multiple topics, it consolidates into a single Subject, and compatibility policies are concentrated in one place.

The benefits are promoting schema reuse and centralizing compatibility policy. On the other hand, carelessly using the same fully qualified name for a different schema can cause collisions. Solid namespace design, naming conventions, and care to avoid reusing record names across keys/values are essential.

  • Subject example: com.example.events.OrderCreated
  • Unifies compatibility across multiple topics
  • Risk of collisions if namespace design is weak
  • Fits organizations that emphasize a shared event/schema foundation

TopicRecordNameStrategy and Comparing the Three Strategies

TopicRecordNameStrategy creates a Subject by combining the topic name with the fully qualified record name. It preserves topic-boundary independence while making it easy to distinguish different record names within the same topic. It is a balanced choice when adopting multi-event topics.

The table below organizes the three strategies by viewpoint. For CCDAK, focus on the often-asked points: "the scope of compatibility" and "when reuse is effective."

  • Subject example: orders-com.example.events.OrderCreated
  • Easy to manage for multi-event topics
  • Less reusable than RecordNameStrategy, but lower collision risk
AspectTopicNameStrategyRecordNameStrategyTopicRecordNameStrategy
Subject example<topic>-key / <topic>-value<namespace.name><topic>-<namespace.name>
Compatibility scopePer topic's key/valueAcross all topics by record nameCombination of topic × record name
Schema reuseLow (tends toward duplicate registration)High (consolidated into a single Subject)Moderate
Collision riskLowMedium-high (same name with different schema collides)Low to medium
Best-fit caseIndependent topic operations, initial adoptionShared event foundation, reusing the same event across multiple topicsMulti-event topics
Exam focusLocalizing impact scopeCross-cutting compatibility and reuseBalanced scope of application

Compatibility and Evolution: The Subject Is the Boundary

Compatibility levels (Backward/Forward/Full/Transitive, etc.) can be set as a global default and overridden per Subject. Regardless of the strategy, evaluation ultimately happens against "that Subject." Therefore, choosing RecordNameStrategy raises the responsibility of maintaining backward compatibility against a single Subject shared by multiple topics.

The combination of auto.register.schemas=false and use.latest.version=true helps with pre-registration and phased rollouts in production. Since producers do not autonomously create new schemas, you can more easily prevent compatibility breakage.

  • Compatibility is per Subject. Strategy choice = boundary design
  • Same-name record collisions surface most easily with RecordNameStrategy
  • Key and value are separate Subjects; you can configure different strategies for each
  • In large organizations, build naming conventions and review into the process

Practical Checklist and Migration Thinking

Inventory your current topics and events, and check which are shared across multiple topics. If sharing is heavy, RecordNameStrategy is natural; if topics are independent, TopicNameStrategy fits better. For multi-event topics, also consider TopicRecordNameStrategy.

Begin migration with new producer settings and leave existing messages as is. Since the wire format resolves via Schema ID, consumers are not affected. However, old and new Subjects coexist after migration. Monitor compatibility policies and the growth in Subject count on the Registry side.

  • When using different strategies for key/value, avoid reusing the same record name
  • Tighten namespaces (e.g., com.company.domain.event)
  • In production, turn off auto.register.schemas and build a pre-registration pipeline
  • During migration, strengthen monitoring of Subject lists and compatibility violations

Check Your Understanding

CCDAK

問題 1

You want to share the same event type OrderCreated across multiple topics (orders, orders_dlq, orders_analytics) and manage schema compatibility centrally in one place. Which Subject naming strategy is appropriate?

  1. RecordNameStrategy
  2. TopicNameStrategy
  3. TopicRecordNameStrategy
  4. Use a custom implementation to embed the Subject name in messages

正解: A

RecordNameStrategy uses the fully qualified record name as the Subject, so the same event type shared across multiple topics consolidates into a single Subject, making centralized compatibility management easy. TopicNameStrategy separates Subjects per topic, and TopicRecordNameStrategy separates them by topic × record name, so neither centralizes as effectively as RecordNameStrategy.

Frequently Asked Questions

Where are compatibility levels configured, and what scope do they affect?

You can set them as a global default (/config) and per-subject (/config/{subject}). Evaluation happens at the Subject level, so regardless of the naming strategy, the final policy applied is the one defined for that specific Subject.

What happens if RecordNameStrategy uses the same fully qualified name for different schemas?

They collide on the same Subject and break registration or compatibility checks. You need strict namespace design, conventions for reusing record names, and schema reviews as part of your workflow.

Does switching from TopicNameStrategy to RecordNameStrategy affect consumers?

Typically not. The wire format only carries the Schema ID, and consumers resolve schemas by ID. The new strategy registers under a new Subject, but existing messages keep IDs tied to the old Subject. During migration, monitor coexisting Subjects and compatibility settings.

Check what you learned with practice questions

Practice with certification-focused question sets

無料で問題を解いてみる
Author

NicheeLab Editorial Team

NicheeLab editorial team focused on data engineering and cloud certification learning. Content is structured around practical study needs and official exam domains.


Related articles
Kafka

Kafka Topics & Partitions: Distribution Fundamentals (2026)

How Kafka topics and partitions enable scale — ordering guar...

Kafka

CCDAK Exam Guide: Confluent Certified Developer (2026)

Complete prep for the CCDAK exam — Producer/Consumer API, St...

Kafka

CCAAK Exam Guide: Confluent Certified Administrator (2026)

Pass the CCAAK exam — cluster management, partitions, securi...

Kafka

Kafka Replicas & ISR: Fault Tolerance Explained (2026)

Replica placement, in-sync replicas (ISR), leader election. ...

Kafka

Kafka Offsets: Commit Modes & Consumer Position (2026)

Offset semantics — auto vs. manual commit, __consumer_offset...

Browse all Kafka articles (101)
© 2026 NicheeLab All rights reserved.