/chatme_kafka

A NodeJs chat server that uses kafka as a distributed message log and a AngularJs client that uses web sockets for a real time chat experience.

Primary LanguageJavaScriptMIT LicenseMIT

Chat With Node, Kafka and AngularJs
============

A NodeJs chat server that uses kafka as a distributed message log
and a AngularJs client that uses web sockets for a real time chat experience.

Setup
============

Install NodeJs from http://nodejs.org/
Install Kafka from http://kafka.apache.org
Install Mongo from https://www.mongodb.com

# Mongo
Create a 'chatme' database

Create a counters collection

db.counters.insert(
   {
      _id: "tempUserId",
      seq: 0
   }
)

Create a nicknames collection

db.createCollection("nicknames");
db.nicknames.createIndex( { "createdAt": 1 }, { expireAfterSeconds: 86400 } );

Create a rooms collection
db.createCollection("rooms");
db.rooms.insert({"name" : "Lobby"});


#Start mongo
mongod --config /usr/local/etc/mongod.conf

#Start Kafka (Quick Start)

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

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

$KAFKA_HOME/bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic chatmessages


cd chatme
npm install
node app.js --port 3000 --groupid chatgroup1
node app.js --port 3001 --groupid chatgroup2
open two browser windows one at localhost:3000 and one at localhost:3001
Start chatting.