This project shows how to use the Apicurio Service Registry to manage Apache Kafka data schemas. This example uses the Avro data format messages to and from a local cluster.
First you need an Apache Kafka cluster. You can follow the instructions from the Apache Kafka website or use the docker-compose.yaml
file in this project.
To start the local development cluster and registry:
-
Be sure Docker Desktop is running.
-
Open a terminal window and execute the following command:
docker-compose -f docker-compose.yaml up
-
Wait until all the components are up and running.
The application is based on Quarkus (using Java 8) so it can be started executing the following command:
./mvnw compile quarkus:dev
This will start the application in the Confluent schema registry compatibility mode.
To use the Apicurio Avro Serializer and Deserializer:
-
Open the
application.properties
file -
Uncomment the
value.serializer
properties to use theio.apicurio.registry.utils.serde.AvroKafkaSerializer
andio.apicurio.registry.utils.serde.AvroKafkaDeserializer
classes instead.mp.messaging.outgoing.price-out.value.serializer=io.apicurio.registry.utils.serde.AvroKafkaSerializer mp.messaging.incoming.price-in.value.deserializer=io.apicurio.registry.utils.serde.AvroKafkaDeserializer
-
Comment the same lines that use the
io.confluent.kafka.*
packages# mp.messaging.outgoing.price-out.value.serializer=io.confluent.kafka.serializers.KafkaAvroSerializer # mp.messaging.incoming.price-in.value.deserializer=io.confluent.kafka.serializers.KafkaAvroDeserializer
-
Uncomment the property using the
apicurio
registrymp.messaging.incoming.price-in.apicurio.registry.url=http://localhost:8080
-
Comment the property using the
schema
registry# mp.messaging.incoming.price-in.schema.registry.url=http://localhost:8080/confluent
To test that everything is workin start again the application with the new configuration values:
./mvnw compile quarkus:dev