Real time notifications for web applications using nodejs, socket.io and redis pubsub

Recently I was working on a real time workflow for a module. I found it really difficult to find good tutorial for the same. I struggled with Flask, gevents and lot of other things and finally settled down to nodejs and socket.io and redis pubsub.

I have written a tutorial for the same https://github.com/roshansingh/realtime-notifications.

The beauty of nodejs is that everything was accomplished in less than 50 lines of code :). Read it and let me know if you have any feedback.

 

  • micheal

    roshan thanks for your article, i wanted to do similar project,
    my requirement is i should start the jobs, that is once the job is started, stored procedure must be executed frequently and update this results to the dashboard.
    and wanted to use mysql instead redis, is it possible
    please help?
    thanks

  • micheal

    node.js should call the stored procedure and reterive the result to the user

  • booking doctor

    thanks for your support, i am deploying a web application for my capstone project. My project using nodejs and your real time notification help me a lot, can you support me more? Regard

    • Sure, tell me what do you want?

      • booking doctor

        I applied the library of sailsjs to my project and it’s working corresponding, thanks

    • booking doctor

      when I insert/update a record into database from user has role A, how can I push a notification to user has role B? I am not sure when applying your code into my project?

      Thanks for your reply

      • Use socket.emit() to broadcast message to one user or if you want to broadcast to multiple users you need to broadcast to a room. For broadcasting to a user, you will need to keep track of user’s socket.

  • Developer Sekar

    Hi Roshan,how to publish message when new message is insert a record into database and update that info to my redis cache array?