I have an existing PHP website and I'm looking to add a real time notification system using node.js
I have outlined the structure of my application into the diagram below :
I'm assuming communication between PHP and Node.js when the notification is generated is the only way I can achieve a realtime notification (unless I recode my entire website in node.js which is not possible)
How do i communicate to node.js from PHP ? (both exist on the same server or atleast the same local LAN)
I have found a few solutions online and on a few SO threads :
Are there other better ways of doing this ?
Also all the notifications are not beamed to all subscribers.
So, a notification generated by User 1 will only be beamed to User 2, 3 and 4 (because of a few business rules of my web app) This permission system needs to be maintained. How do I make sure that all the subscribers do not receive all notifications ?
What is the most efficient way to achieve this ?
I know this answer comes up really late but I've run across the same problem a couple of days ago.
Our solution to this would be using a message broker like RabbitMQ in the middle. Basically, PHP as the producer
creates messages when there is something to be pushed, and Node.js, on the other side as a consumer
listens to the queues and publishes messages whenever there is something new.
This method has a couple of advantages over a direct communication between PHP and Node.js.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With