@optum/knack-consumer

1.0.0 • Public • Published

knack-consumer

A module for consuming messages from Apache Kafka.

Usage

first things first...

$ npm i @optum/knack-consumer node-rdkafka@2.7

options

  • topics: [Array] array of topics to subscribe
  • consumerConfig: [Object] librd consumer config
  • topicConfig: [Object] librd topic config
  • flowMode: [Boolean] run flow mode or control message intake cadence
  • logger: [Object] logger object with trace, debug, info, error methods
  • onData: Function handler for each record consumed

Examples

const knackConsumer = require("@optum/knack-consumer");

const consumerConfig = {
	"client.id": "my-kafka-client-v1",
	"group.id": "my-kafka-group-v1",
	"metadata.broker.list": "localhost:9092",
	"socket.keepalive.enable": true,
	"enable.auto.commit": true
};

const topicConfig = {
	"auto.offset.reset": "earliest",
	// eslint-disable-next-line camelcase
	event_cb: () => {}
};

const topic = "knack-test-topic-v1";

const handler = ({ key, value, topic, timestamp }) => {
	// do stuff with record
};

// connect consumer with options
const testConsumer = await knackConsumer.connect({
	topics: [topic],
	consumerConfig,
	topicConfig,
	onData: handler
});

process.on("SIGINT", async () => {
	await knackConsumer.disconnect();
});

Readme

Keywords

Package Sidebar

Install

npm i @optum/knack-consumer

Weekly Downloads

3

Version

1.0.0

License

Apache-2.0

Unpacked Size

18.1 kB

Total Files

4

Last publish

Collaborators

  • nthurow_uhg
  • npeschel
  • robertcrockett
  • ryantrapp
  • alex.aavang
  • eric-hc
  • tiffkwin
  • amyschoen
  • bwoodrin