kafka-connector
v0.1.6
Published
A kafka connector built on top of kafkajs
Downloads
18
Readme
Description
[kafka-connector]A public TypeScript library for easy kafka producer and consumer.
Installation
$ npm i kafka-connector
How to use?
Step 1 - Initilize KafkaManager, you can use custom host and port.
this.kafkaManager = await KafkaManager.create(); //
await this.kafkaManager.initilize({ host: 'localhost', 'port': 29092});
Step 2 - Consume existing topic
await this.kafkaManager.consume(
{ topic: 'customtopic' }, {
eachMessage: async ({ topic, partition, message }) => {
console.log({
topic: topic.toString(),
partition: partition.toString(),
value: message.value.toString()
})
}
});
Step 3 - Produce to existing or new topic
await kafkaManager.produce({
topic: 'customtopic', messages: [
{
key: 'create user',
value: 'Hi, New event happended!!'
}
]
})
Test
# unit tests
$ npm run test
# e2e tests
$ npm run test:e2e
# test coverage
$ npm run test:cov
Stay in touch
- Author - Tofeeq Ahmad
License
Nest is MIT licensed.