Unleashconf 2017 - Kafka integration example
- Nodejs v6.9.1+
- Yarn 1.2.1+
- Docker (optional)
$ git clone https://github.com/desiter/kafka-chat.git
$ yarn $ yarn run producer --broker=host:port --topic=some_topic [--key=the_key]Paremeters:
--brokeris required unless you are about to connect the local docker-composed default kafka broker--topicdesired topic name to send a message to (defaults toUnleashChat)--keyomit unless you want to force total order over all messages sent here
$ yarn run consumer --broker=host:port --topic=some_topic --group=some_groupParemeters:
--brokeris required unless you are about to connect the local docker-composed default kafka broker--topicdesired topic name to subscribe to (defaults toUnleashChat)--group(optional) your consumer group (defaults totest)
You can spin up your own local kafka cluster by running the following command
$ nano ./docker-compose.yml # put your IP address first
$ docker-compose up -dNOTICE: the docker based Kafka cluster requires your machine IP address to handle broker host advertising. Since localhost or 127.0.0.1 can be resolved only locally the cluster will not work if you're connecting from another machine.