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.

You must have produced data in Avro format.
  1. Navigate to Management Console > Environments, and select the environment where your Kafka cluster is running.
  2. On the Data Hubs tab of your environment, select the Kafka cluster you created.
  3. Click Schema Registry on the Services pane to open the Schema Registry web UI.
    One schema registered with the name of the topic being used is displayed.
  4. Click on the machine-data-avro schema to expand:

    In this page, you can view all the versions of the schema. You only see version v1, which is the version just registered by the producer’s KafkaAvroSerializer.