Listen/Notify in postgres

vindica=# listen channel_foo;
LISTEN














vindica=# select 1;
 ?column? 
----------
        1
(1 row)

Asynchronous notification "channel_foo" 
with payload "payload" received
from server process with PID 32457.
vindica=# 







vindica=# notify channel_foo, 'payload';
NOTIFY

Publisher

Subscriber

Features

  • Anyone in the DB can listen to any channel, so nothing special in terms of security.
  • NOTIFY will be triggered only when the transaction commits
  • LISTEN will be triggered only when the transaction ends (commit or rollback)
  • Both LISTEN and NOTIFY connections can be used for other queries while 'listening' or 'notifying'

Perl Drivers

It is supported since release from the perl Pg Driver:

https://metacpan.org/pod/Pg::PQ

Questions ?

Listen/Notify in postgres

By Zlatin Stanimirov

Listen/Notify in postgres

  • 929