Class RecordNameStrategy

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

public class RecordNameStrategy extends Object implements SubjectNameStrategy
For any record type that is published to Kafka, registers the schema in the registry under the fully-qualified record name (regardless of the topic). This strategy allows a topic to contain a mixture of different record types, since no intra-topic compatibility checking is performed. Instead, checks compatibility of any occurrences of the same record name across all topics.
  • Constructor Details

    • RecordNameStrategy

      public RecordNameStrategy()
  • Method Details

    • configure

      public void configure(Map<String,?> config)
      Specified by:
      configure in interface org.apache.kafka.common.Configurable
    • usesSchema

      public boolean usesSchema()
      Description copied from interface: SubjectNameStrategy
      Whether the strategy depends on the schema.
      Specified by:
      usesSchema in interface SubjectNameStrategy
      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
      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.
    • getRecordName

      protected String getRecordName(ParsedSchema schema, boolean isKey)
      If the schema is a record type, returns its fully-qualified name. Otherwise throws an error.