Class TopicRecordNameStrategy

java.lang.Object
io.confluent.kafka.serializers.subject.RecordNameStrategy
io.confluent.kafka.serializers.subject.TopicRecordNameStrategy
All Implemented Interfaces:
SubjectNameStrategy, org.apache.kafka.common.Configurable

public class TopicRecordNameStrategy extends RecordNameStrategy
For any record type that is published to Kafka topic <topic>, registers the schema in the registry under the subject name <topic>-<recordName>, where <recordName> is the fully-qualified record name. This strategy allows a topic to contain a mixture of different record types, since no intra-topic compatibility checking is performed. Moreover, different topics may contain mutually incompatible versions of the same record name, since the compatibility check is scoped to a particular record name within a particular topic.
  • Constructor Details

    • TopicRecordNameStrategy

      public TopicRecordNameStrategy()
  • Method Details

    • usesSchema

      public boolean usesSchema()
      Description copied from interface: SubjectNameStrategy
      Whether the strategy depends on the schema.
      Specified by:
      usesSchema in interface SubjectNameStrategy
      Overrides:
      usesSchema in class RecordNameStrategy
      Returns:
      Whether the strategy depends on the schema.
    • subjectName

      public String subjectName(String topic, boolean isKey, ParsedSchema schema)
      Description copied from interface: SubjectNameStrategy
      For a given topic and message, returns the subject name under which the schema should be registered in the schema registry.
      Specified by:
      subjectName in interface SubjectNameStrategy
      Overrides:
      subjectName in class RecordNameStrategy
      Parameters:
      topic - The Kafka topic name to which the message is being published.
      isKey - True when encoding a message key, false for a message value.
      schema - the schema of the record being serialized/deserialized
      Returns:
      The subject name under which the schema should be registered.