Loopback kafka consumer middleware
This is a simple middleware listening for kafka events on a speficied topic.
INSTALL
npm install loopback-kafka-consumer-middleware --save
SERVER CONFIG
Add the middleware to your middleware.json:
HANDLER
You need to define an event handler (in the previous example config, kafkaEventHandler.js) with the following structure in the loopback server directory.
'use strict'; moduleexports = { console; } { console; } { console; };
CONNEXIONS
To be able to connect to your kafka host or zookeeper host and listen for events in the topic, you have to set the KAFKA_URL and KAFKA_TOPIC env variables
export KAFKA_URL=192.168.99.100:2181export KAFKA_TOPIC=node-test