Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Architecture Implementation and Design for a Notification System using socket.io node.js and incoming messages

Disclaimers

  • I have not worked with node.js before
  • I have not used socket.io before

I'm looking at implementing a Google Plus, Facebook, StackOverflow style notification system. I'm not an inexperienced developer, and eventually I will figure this out, but I'm just looking for a thrust to the right direction.

What I want is for users who are browsing my site to be notified during their browsing session when they receive a new message.

Currently, all of my messages are stored in a single table.

  |  id    | messageSubject   | messageBody     | hasRead   | readDate   | sentDate   | sentToUser  | sentFromUser  |
  |   1    |   HelloWorld     | Nada            |   0       | `null`     | `null      |      1      |      10       |

Now, all of my messages are retrieved from dozens of different sources.

  • A message can be entered via an API by third parties
  • Message are pulled from Send Grid
  • Messages can be sent via private message Controllers.
  • Etc etc

What I want is to have a way to be able to notify users when a new message is received. I'm happy to refactor my code any way which makes it possible to notify my node.js when I receive a insert a message if that is what I need to do.

But I am just not quite sure where to start.

My problem is that all of my messages are entered into mysql through dozens of different sources, my Insert statements are in a lot of areas. So I just don't know the best way to proceed.

Thanks.

like image 835
Layke Avatar asked Aug 24 '11 22:08

Layke


People also ask

How do I send a notification using socket IO?

In that event we are sending or emit event 'recieveNotifications' to specific user by using io.to() here we can use either io.to or io.in both are same, we just need to pass the group or channel name here. If you want to send the notification to every user then use socket. broadcast. emit('eventName', data);

How do you send a message to a specific user in socket IO?

You can use socket.io rooms. From the client side emit an event ("join" in this case, can be anything) with any unique identifier (email, id). Server Side: io.sockets.in('[email protected]').

Is socket IO good for chat?

This is an organization based application. In this app, I have to implement chat functionality. So as we all know Socket.io is the best solution for instant messaging app and its reliability.


1 Answers

Try to look at presentation Why databases suck for messaging which is namely about why you shouldn't use databases such as MySQL for messaging. Messaging and notifications systems works well with Event Driven Architecture and I would recommend to watch this presentation or to learn more on this topic from here in order to get a bigger picture about event driven "ecosystem".

like image 102
yojimbo87 Avatar answered Oct 04 '22 14:10

yojimbo87