postgresql - How can a postgres 9.4 server know if a client is listening on a notify channel? -


i have situation want send out notification users if have been added particular table in postgresql db.

i using pg_notify send out json payload node.js server has implemented pg client listen on notification channel. works well.

what can't decide how best inform postgres server listening , notify received , being processed. ideally use same channel client notify server. however, understand it, postgres server act hub channel, receiving notification client , pushing other subscribed listeners.

is case? can build function on postgres server triggered incoming notifications on channel?

the other solution occurs me have column in table record notification has been received node.js server update table on receipt of notification, requires additional connection avoid.

any thoughts or experience appreciated.

the solution depends on how important not miss notification.

no, postgres doesn't have functionality listen notifications clients, if connected postgres server need done directly.

postgres not message queue. gives listen/notify can build more complex things with, unless know doing isn't advise.

if need guaranteed delivery of messages, routing of messages, better off using real message queue rabbitmq part.

you example have simple application listen on notifications postgres , put them on message queue, keeps message until has read , acknowledged it.

if application fails miss messages if need better guarantees have trigger in postgresql puts messages in table backup.


Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -