Architecture Implementation and Design for a Notif

2019-03-09 03:58发布

问题:

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.

回答1:

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".