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 :

enter image description here

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 :

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

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -