kafka-wrapper-library

0.1.4 • Public • Published

kafka-wrapper-library

A Kafka wrapper library for Kafka Consumers and Producers, made in Typescript.

Producer

Sending message

	producer.sendMessages("another_new_topx", 0, "new_msg", new kafka.KeyedMessage('keyed', 'a keyed message'))
	.then(value => {
	console.log(value);
    });

Creating a topic

producer_create_topic.createTopic("another_new_topx", true, null)
	.then(value => {
		console.log(value);
	});

Consumer

Consuming a topic

	.Consume(null, null);

High Level Producer

Sending a message

high_producer.sendMessages("another_new_topx", new kafka.KeyedMessage('keyed', 'a keyed message'))

Creating a topic

high_producer_create_topic.sendMessages("random_topic")

KafkaConsumerGroup

let new_comsumer_1 = consumerGroup.consumerInitiate('consumer1', 'another_new_topx');
new_comsumer_1.on('error', consumerGroup.onError);
new_comsumer_1.on('message', function () {
		new_comsumer_1.close(true, function (error) {
			console.log('consumer1 closed', error);
		});
});
new_comsumer_2.on('error', consumerGroup.onError);
new_comsumer_2.on('message', consumerGroup.onMessage);
new_comsumer_2.on('connect', function () {
	setTimeout(function () {
		new_comsumer_2.close(true, function (error) {
			console.log('consumer2 closed', error);
		});
	}, 25000);
});

let new_comsumer_3 = consumerGroup.consumerInitiate('consumer3', 'another_new_topx');
new_comsumer_3.on('error', consumerGroup.onError);
new_comsumer_3.on('message', consumerGroup.onMessage);

ProducerStream

Not functional yet!

producer_stream.sendMessages("another_new_topx", new kafka.KeyedMessage('keyed', 'a keyed message'))

Readme

Keywords

none

Package Sidebar

Install

npm i kafka-wrapper-library

Weekly Downloads

1

Version

0.1.4

License

none

Unpacked Size

31.4 kB

Total Files

24

Last publish

Collaborators

  • ricardo-pinho