Avro Serializer/Deserializer for Confluent Schema Registry is an Avro serializer/deserializer designed to work with the Confluent Schema Registry. It is designed to not include the message schema in the message payload but instead includes the schema ID.
The Ballerina Avro Serializer/Deserializer for Confluent Schema Registry connector integrates with the Confluent Schema Registry for Avro serialization and deserialization.
To use the Confluent schema registry connector in your Ballerina project, modify the .bal
file as follows.
Import the ballerinax/confluent.cavroserdes
module into your Ballerina project.
import ballerinax/confluent.cavroserdes;
You can now utilize the operations available within the connector. To instantiate a cregistry:Client
instance refer to the guidelines here.
public function main() returns error? {
cregistry:Client registry = ; // instantiate a schema registry client
string schema = string `
{
"type": "int",
"name" : "value",
"namespace": "data"
}`;
int value = 1;
byte[] bytes = check cavroserdes:serialize(registry, schema, value, "subject");
int number = check cavroserdes:deserialize(registry, bytes);
}
Use the following command to compile and run the Ballerina program.
bal run
The Ballerina Avro Serializer/Deserializer connector for Confluent Schema Registry provides practical examples illustrating usage in various scenarios. Explore these examples.
-
Kafka Avro producer - This example demonstrates how to publish Avro serialized data to a Kafka topic.
-
Kafka Avro consumer - This guide demonstrates how to consume data in the correct format according to the Avro schema from a Kafka topic.
The Issues and Projects tabs are disabled for this repository as this is part of the Ballerina library. To report bugs, request new features, start new discussions, view project boards, etc., visit the Ballerina library parent repository.
This repository only contains the source code for the package.
-
Download and install Java SE Development Kit (JDK) version 17. You can download it from either of the following sources:
Note: After installation, remember to set the
JAVA_HOME
environment variable to the directory where JDK was installed. -
Download and install Ballerina Swan Lake.
-
Download and install Docker.
Note: Ensure that the Docker daemon is running before executing any tests.
-
Generate a Github access token with read package permissions, then set the following
env
variables:export packageUser=<Your GitHub Username> export packagePAT=<GitHub Personal Access Token>
Execute the commands below to build from the source.
-
To build the package:
./gradlew clean build
-
To run the tests:
./gradlew clean test
-
To build the without the tests:
./gradlew clean build -x test
-
To debug package with a remote debugger:
./gradlew clean build -Pdebug=<port>
-
To debug with Ballerina language:
./gradlew clean build -PbalJavaDebug=<port>
-
Publish the generated artifacts to the local Ballerina central repository:
./gradlew clean build -PpublishToLocalCentral=true
-
Publish the generated artifacts to the Ballerina central repository:
./gradlew clean build -PpublishToCentral=true
As an open source project, Ballerina welcomes contributions from the community.
For more information, go to the contribution guidelines.
All contributors are encouraged to read the Ballerina Code of Conduct.
- For more information go to the confluent.cavroderdes library.
- Discuss code changes of the Ballerina project in [email protected].
- Chat live with us via our Discord server.
- Post all technical questions on Stack Overflow with the #ballerina tag.