Skip to content

Using a redis server, and node js node, and socket.io, I have established a PubSub model.

Notifications You must be signed in to change notification settings

GautamGadipudi/Node-Redis-PubSub

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Node-Redis-PubSub

Using a redis server, and node js node, and socket.io, I have established a PubSub model.

  • Step 0: Run the following commands in your terminal:

    npm install express socket.io redis body-parser uuid --save
  • Step 1: Run the redis server in another terminal using the command:

    redis-server
  • Step 2: Run the publisher server in another terminal using:

    node publisher.js
  • Step 3: Run the subscriber server in another terminal using:

    node subscriber.js
  • Step 4: Open a browser and connect to the subscriber using:

    localhost:3001/mychannel?username=yourname
  • Step 5: Open postman and send a POST request to localhost:3000.

    Note: The request must be a JSON object as below:

    {
      "type": "CLIENT_ID",
      "userId" : "yourname",
      "payload": {
        "txn": "cred",
        "amount": "3000",
        "allother": "payload"
      }
    }	 
  • Step 6 Now in the browser console (enable logging and JS). You should be able to see the payload of the respective userID. You can also open multiple clients to the subscriber server with different usernames.

About

Using a redis server, and node js node, and socket.io, I have established a PubSub model.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published