Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using LISTEN / NOTIFY in psql clients

I'm connected to same database server running in Docker container via psql client.

  1. In client A I run listen "virtual";
  2. In client B I run notify "virtual";

I would expect to see some kind of output in client A that it received asynchronous notification.

Can psql client be used this way?

like image 797
user3056783 Avatar asked Oct 16 '25 12:10

user3056783


1 Answers

The notification is only retrieved from the server as a payload to a request. If the client does not send a request to the server, it will not see the notification.

In psql you can run an empty statement (only a ;) to do that:

someuser=> ;
Asynchronous notification "virtual" received from server process with PID 11284.
someuser=>

Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!