Checking schema registration
When the KafkaAvroSerializer
is used to produce data to a Kafka
topic, the serializer first checks with the configured Schema Registry service to ensure
that the schema is compatible with the one registered for that Kafka topic. You can view the
registered schema and its the versions in the Schema Registry web UI.
If the Kafka topic does not have the schema registered yet, the serializer registers the schema on behalf of the client, provided it has permissions to do so. If there is a schema registered for the Kafka topic, the serializer checks if the schema being used by the client is either the same or a compatible version of that schema.
If the schema is the same, the producer uses it for producing messages. If the schema is a new version of the currently registered schema that is compatible with the previous versions, the serializer registers it with a new version number and then uses it for producing messages. If the schema being used by the client is not compatible with the currently registered schema, the serializer issues an exception.
In this example, because this is the first time that you used that topic, there was
previously no schema registered for it. If everything works as expected, the schema
defined in the MachineData.v1.avsc
file is successfully registered
in Schema Registry.