Schema Registry

Confluent Schema Registry

  • Confluent Schema Registry is a Confluent product that stores and manages schemas for Kafka messages, not a part of Apache Kafka.

  • Subject

    • A serializer registers a schema in Schema Registry under a subject name, which defines a namespace in the registry.

    • Subject name is determined by the subject name strategy (opens in a new tab).

      • io.confluent.kafka.serializers.subject.TopicNameStrategy (default)

        • default
        • $topic_name plus -key or -value depending on configuration
        • $fully_qualified_record_name
        • $topic_name-$fully_qualified_record_name
      • io.confluent.kafka.serializers.subject.RecordNameStrategy

        The subject name is the fully-qualified name of the record type.

        The schema registry checks the compatibility for a particular record type, regardless of topic.

      • TopicRecordNameStrategy

        The subject name is <topic>-<type>, where <topic> is the Kafka topic name, and <type> is the fully-qualified name of the Avro record type of the message.

        This setting also allows any number of event types in the same topic, and further constrains the compatibility check to the current topic only.

  • Testing

  • Resources

Schema Registry Maven Plugin

Schema Registry Client

  • Challenges

    • CachedSchemaRegistryClient is a REST client and retrieves schema from remote Schema Registry, which centrally manage all schemas.

    • MockSchemaRegistryClient uses single-instance in-memory store as the Schema Registry and doesn't share it among instances.

      MockSchemaRegistryClient is not thread safe, so need to be careful when used as singleton for test cases.

Schema Registry Client - Implementations

Schema Registry Client - Mock

Schema Registry Client - AvroSchemaUtils (opens in a new tab)

Schema Registry Client - JsonSchemaUtils (opens in a new tab)

Schema Registry API reference

Schema Registry API - List all subjects

curl -s http://$SCHEMA_REGISTRY_URL/subjects | jq

Schema Registry API - List all schemas

curl -s http://$SCHEMA_REGISTRY_URL/schemas | jq

Schema Registry API - Get a schema with a specified schema ID

curl -s http://$SCHEMA_REGISTRY_URL/schemas/ids/$SCHEMA_ID | jq

Troubleshooting - org.apache.kafka.common.errors.SerializationException: Unknown magic byte