RESTful NodeJS api to achive Basic synchronization mechanism in NodeJS using pub/sub model.
I have choosen Apache Kafka has pub/sub messaging system for this test. Apache Kafka is a fast, scalable, durable, and fault-tolerant publish-subscribe messaging system. Kafka is often used in place of traditional message brokers like JMS and AMQP because of its higher throughput, reliability and replication.
We can easily switch the messaging system from kafka to other client, that code is demonstrated here Messaging tools/software should be interchangeable easily
Java 8, Maven 3.0 and above Download Kafka from Apache Kafka
Step 1: Extract the kafka
$ tar -xzf kafka_2.11-0.9.0.0.tgz
$ cd kafka_2.11-0.9.0.0
Step 2: Start the zookeeper
$ bin/zookeeper-server-start.sh config/zookeeper.properties &
Step 3: Start the Kafka server
$ bin/kafka-server-start.sh config/server.properties
Step 4: Create the topics
$ bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic sync-service
$ bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic invalid-sync-service
Requires Node.js v4+ to run. Required git [plugins/github/README.md] [PlGh]
Install the dependencies and devDependencies and start the server.
$ git clone https://github.com/ManuGowda/sync-service
$ cd sync-service
$ npm install
$ npm install -g gulp
Build the solution with test cases.
$ cd sync-service
$ gulp
$ cd sync-service
$ node server/app.js
$ cd sync-service
$ node client/consumer.js
curl -H "Content-Type: application/json" -X POST -d '{"message":"test"}' http://localhost:8083/sync