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. If there is a configuration property named "subject.name.strategy.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 one 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 "subject.name.strategy.fallback.type" is set to "RECORD", "TOPIC_RECORD", or "NONE".
  • Field Details

  • Constructor Details

    • AssociatedNameStrategy

      public AssociatedNameStrategy()
    • AssociatedNameStrategy

      public AssociatedNameStrategy(com.google.common.base.Ticker ticker)
  • 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.
    • setKafkaClusterId

      public void setKafkaClusterId(String clusterId)
      Description copied from interface: SubjectNameStrategy
      Set the Kafka cluster ID discovered via ClusterResourceListener.
      Specified by:
      setKafkaClusterId in interface SubjectNameStrategy
    • getKafkaClusterId

      protected String getKafkaClusterId()
    • getFallbackSubjectNameStrategy

      protected SubjectNameStrategy getFallbackSubjectNameStrategy()