Class AssociatedNameStrategy

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

public class AssociatedNameStrategy extends Object implements SubjectNameStrategy
A SubjectNameStrategy that will query schema registry for the associated subject name for the topic. The topic is passed as the resource name to schema registry. If there is a configuration property named "kafka.cluster.id", then its value will be passed as the resource namespace; otherwise the value "-" will be passed as the resource namespace. If more than subject is returned from the query, an exception will be thrown. If no subjects are returned from the query, then the behavior will fall back to TopicNameStrategy, unless the configuration property "fallback.subject.name.strategy.type" is set to "RECORD", "TOPIC_RECORD", or "NONE".
  • Field Details

  • Constructor Details

    • AssociatedNameStrategy

      public AssociatedNameStrategy()
  • Method Details

    • configure

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

      public void setSchemaRegistryClient(SchemaRegistryClient client)
      Description copied from interface: SubjectNameStrategy
      Set the schema registry client.
      Specified by:
      setSchemaRegistryClient in interface SubjectNameStrategy
    • 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.