How to communicate between node.js and PHP? -
i have existing php website , i'm looking add real time notification system using node.js
i have outlined structure of application diagram below :
i'm assuming communication between php , node.js when notification generated way can achieve realtime notification (unless recode entire website in node.js not possible)
how communicate node.js php ? (both exist on same server or atleast same local lan)
i have found few solutions online , on few threads :
- using redis pubsub : http://xmeng.wordpress.com/2011/11/14/pubsub-in-redis-using-php/
- using dnode : http://bergie.iki.fi/blog/dnode-make_php_and_node-js_talk_to_each_other/
are there other better ways of doing ?
also notifications not beamed subscribers.
so, notification generated user 1 beamed user 2, 3 , 4 (because of few business rules of web app) permission system needs maintained. how make sure subscribers not receive notifications ?
what efficient way achieve ?
i know answer comes late i've run across same problem couple of days ago.
our solution using message broker rabbitmq in middle. basically, php producer
creates messages when there pushed, , node.js, on other side consumer
listens queues , publishes messages whenever there new.
this method has couple of advantages on direct communication between php , node.js.
- first of all, async. therefore, user perform action , doesn't have wait.
- if, reason, node.js fails, since messages stored in rabbitmq, once restart node continue stopped.
- you have php , node.js loosely coupled.
- it works.
Comments
Post a Comment