Re: pg_listening_channels()

From: "Greg Sabino Mullane" <greg(at)turnstep(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: pg_listening_channels()
Date: 2012-11-30 04:34:09
Message-ID: e4d8ffe21cee1cfa8a321ca1b99dd3f0@biglumber.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


-----BEGIN PGP SIGNED MESSAGE-----
Hash: RIPEMD160

Igor Neyman wrote:
> But, I (and probably many others) use LISTEN/NOTIFY mechanism to notify
> client program connected to postgres database about changes made in the database

Yes, it is commonly used for that.

> Implementation prior to PG 9.0:

> INTERESTED_CLIENT: LISTEN my_alert;
> SOME_OTHER_PROGRAM: INSERTS/UPDATES/DELETES table_client_interested_in;
> ON INSERT/UPDATE/DELETE TRIGGER: check if anyone listens on "my_alert"
> channel by querying pg_listener table, sends NOTIFY my_alert signal
> and inserts message into user_message_table;
> INTERESTED_CLIENT: upon receiving NOTIFY signal reads message from
> user_message_table;

> With PG 9.0 changes I lost ability to check if anyone is interested
> in the NOTIFY signal and payload I'm about to send. Seems like this
> change was not thought through completely.

On the contrary, it was very well discussed and designed. Why do you
even care if the anyone is listening or not? Simply remove the
"check if anyone listens" step and send the NOTIFY.

If you really need to know if anyone is listening, set up a two-way
stream of listen/notify.

- --
Greg Sabino Mullane greg(at)turnstep(dot)com
PGP Key: 0x14964AC8 201211292331
http://biglumber.com/x/web?pk=2529DF6AB8F79407E94445B4BC9B906714964AC8
-----BEGIN PGP SIGNATURE-----

iEYEAREDAAYFAlC4NykACgkQvJuQZxSWSsjNBACfXRI+7IIcFl1COSf+Oe7u8kuU
PhUAn26FHWjQa2yJAP7CmAMWNGLVUQyJ
=xZ4p
-----END PGP SIGNATURE-----

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Gavan Schneider 2012-11-30 05:34:15 Re: youtube video on pgsql integrity
Previous Message Greg Sabino Mullane 2012-11-30 04:27:53 Re: Question about PostgreSQL logging configuration