Confluent Schema Registry
-
Confluent Schema Registryis aConfluentproduct that stores and manages schemas for Kafka messages, not a part ofApache Kafka. -
Subject-
A serializer registers a schema in
Schema Registryunder asubjectname, which defines a namespace in the registry. -
Subjectname is determined by the subject name strategy (opens in a new tab).-
io.confluent.kafka.serializers.subject.TopicNameStrategy (default)- default
$topic_nameplus-keyor-valuedepending on configuration$fully_qualified_record_name$topic_name-$fully_qualified_record_name
-
io.confluent.kafka.serializers.subject.RecordNameStrategyThe 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.
-
TopicRecordNameStrategyThe 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
-
Confluent
-
io.confluent.kafka.schemaregistry.client.CachedSchemaRegistryClient (opens in a new tab)
Thread safe, can be used as a singleton Spring bean
-
Schema Registry Client - Mock
-
io.confluent.kafka.schemaregistry.testutil.MockSchemaRegistry (opens in a new tab)
-
io.confluent.kafka.schemaregistry.client.MockSchemaRegistryClient (opens in a new tab)
- Not thread safe
- In-memory store per instance
-
Resources
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 | jqSchema Registry API - List all schemas
curl -s http://$SCHEMA_REGISTRY_URL/schemas | jqSchema Registry API - Get a schema with a specified schema ID
curl -s http://$SCHEMA_REGISTRY_URL/schemas/ids/$SCHEMA_ID | jq