duysmile / kafka-node-example

This is a example for combining kafka and nodejs

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

kafka-nodejs

Install kafka

Download from here

Run zookeeper

bin/zookeeper-server-start.sh config/zookeeper.properties

Run server (broker)

bin/kafka-server-start.sh config/server.properties

Create topic

bin/kafka-topics.sh --create --bootstrap-server localhost:9092 --replication-factor 1 --partitions 1 --topic test

Send message

  • Using command line

bin/kafka-console-producer.sh --broker-list localhost:9092 --topic test message 1

  • Using nodejs

node producer.js

Consume message

  • Using command line

bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic test --from-beginning

  • Using nodejs

node consumer.js

About

This is a example for combining kafka and nodejs


Languages

Language:JavaScript 100.0%