If you have producer or consumer applications created in languages other than Java, use the following guidance to set them up to use schemas. You can also use the REST producer API to send messages that are encoded with a schema.
Important: Support for Apicurio client libraries version 2.3.x and earlier is deprecated. Ensure all applications connecting to Event Streams that use the schema registry are using Apicurio client libraries version 2.4.1 or later, then migrate to the latest Apicurio.
For a producer application:
- Retrieve the schema definition that you will be using from Apicurio Registry in Event Streams and save it in a local file.
- Use an Apache Avro library for your programming language to read the schema definition from the local file and encode a Kafka message with it.
- Set the schema registry headers in the Kafka message, so that consumer applications can understand which schema and version was used to encode the message, and which encoding format was used.
- Send the message to Kafka.
For a consumer application:
- Retrieve the schema definition that you will be using from Apicurio Registry in Event Streams and save it in a local file.
- Consume a message from Kafka.
- Check the headers for the Kafka message to ensure they match the expected schema ID and schema version ID.
- Use the Apache Avro library for your programming language to read the schema definition from the local file and decode the Kafka message with it.
Retrieving the schema definition from the schema registry
Using the UI
- Log in to your Event Streams UI as an administrator from a supported web browser (see how to determine the login URL for your Event Streams UI).
- Click Schema registry in the primary navigation and find your schema in the list.
-
Copy the schema definition into a new local file.
- For the latest version of the schema, expand the row. Copy and paste the schema definition into a new local file.
- For a different version of the schema, click on the row and then select the version to use from the list of schema versions. Click the Schema definition tab and then copy and paste the schema definition into a new local file.
Using the CLI
- Initialize the Event Streams CLI by following the instructions in logging in.
-
Run the following command to list all the schemas in the schema registry:
kubectl es schemas
-
Select your schema from the list and run the following command to list all the versions of the schema:
kubectl es schema <schema-name>
-
Select your version of the schema from the list and run the following command to retrieve the schema definition for the version and copy it into a new local file:
kubectl es schema <schema-name> --version <schema-version-id> > <schema-definition-file>.avsc
Note: <schema-version-id>
is the integer ID that is displayed when listing schema versions using the following command:
kubectl es schema <schema-name>