2

I'm trying to figure out the best way possible to notify my web-application of database changes. The way I'm doing it now, is that I've got separate MySQL table with a counter.

Now, when some database action happens in table Foo, a trigger is adding up the counter. The web-app then polls every 5 seconds the server to check out, if something has happened (counter number has changed) and if so, refresh the data in app.

What I would like, is that I would be able to do callback/notify from MySQL to the server and from there to the web-app so that I don't need to poll the server frequently. Is this possible somehow?

nhaa123
  • 9,570
  • 11
  • 42
  • 63
  • try http://gonzalo123.wordpress.com/2011/05/09/real-time-monitoring-php-applications-with-websockets-and-node-js/ with http://meteor.com/ realtime php – andres descalzo Sep 01 '12 at 20:54

2 Answers2

0

How does facebook, gmail send the real time notification? You can't notify your application directly from MySQL, but there are some solutions to save bandwith and load of your server.

Community
  • 1
  • 1
stil
  • 5,306
  • 3
  • 38
  • 44
0

one way of handling this - would be to either implement the observer pattern yourself or simply use a pubsub messaging option (ZMQ/AMQ/RabbitMQ/Redis etc) - when the initial database action takes place (ensure that the transaction has committed), publish the message to the topic on the pubusb tool - your application can subscribe to the pubsub tool and receive messages when there is a DB change.

Hope it helps.

ali haider
  • 19,175
  • 17
  • 80
  • 149