kafka-avro-nodejs

1.0.5 • Public • Published

kafka-avro-nodejs

This module is used for implementing kafka-avro using node.js

The kafka-avro-nodejs library is a wrapper that combines the kafka-avro, node-rdkafka and avsc libraries to allow for Production and Consumption of messages on kafka validated and serialized by Avro.

Install

For Ubuntu 16.04 and above please follow the below step before installing the module:

sudo apt install librdkafka-dev

Install the module using NPM:

npm install kafka-avro-nodejs --save

Implementation

  • Run the docker-compose.yml file to run schema-registry,zookeeper and kafka (optional) (make sure to replace localhost with your IP)
  • Create schemas in schema registry using API's specified here
  • Please refer producer.js and consumer.js to use this module
  • Provide all configurations in config.js as shown
  • Please make sure schemas are created in the schema registry first

Sample schema registration commands

  • curl -X POST -H "Content-Type: application/vnd.schemaregistry.v1+json" --data '{"schema": "{"type": "record", "name": "avrotest_value", "fields": [{"type": "string", "name": "id"},{"type": "string", "name": "name","default": "na"}]}"}' http://localhost:8081/subjects/avrotest-value/versions

  • curl -X POST -H "Content-Type: application/vnd.schemaregistry.v1+json" --data '{"schema": "{"type": "record", "name": "avrotest_value", "fields": [{"type": "string", "name": "id"},{"type": "string", "name": "name","default": "na"}]}"}' http://localhost:8081/subjects/avrotest-key/versions

Tools useful to create

Readme

Keywords

none

Package Sidebar

Install

npm i kafka-avro-nodejs

Weekly Downloads

0

Version

1.0.5

License

ISC

Unpacked Size

84.1 kB

Total Files

21

Last publish

Collaborators

  • accionlabs