@3g/kafka-wrapper

A lightweight Kafka wrapper that creates listeners and publisher.

Usage no npm install needed!

<script type="module">
  import 3gKafkaWrapper from 'https://cdn.skypack.dev/@3g/kafka-wrapper';
</script>

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);
});

Notes

Consumer Groups