@3g/kafka-wrapper
v2.0.4
Published
A lightweight Kafka wrapper that creates listeners and publisher.
Downloads
18
Readme
Kafka Wrapper
A lightweight Kafka wrapper that creates listeners and publisher.
Currently uses node-rdkafka
behind the scenes.
Usage
Listener
const listener = kafkaListener({
host: '127.0.0.1:29092',
groupId: 'testing.123',
topics: ['test-wrapper'],
}, (message: IMessage) => {
console.log('here be msgs', message);
console.log('message value', message.value.toString());
}, (err: Error) => {
console.error('Err', err);
});
Publisher
const publisher = kafkaPublisher({
host: '127.0.0.1:29092',
clientId: 'testing-wrapper-publisher',
}, (err: Err) => {
console.error('Err', err);
});
publisher.send({
topic: 'test-wrapper',
message: {
stuff: 123,
},
}).then(() => {
console.log('Message sent successfully', i);
}).catch(err => {
console.error('Err sending message', err);
});