Re: Who is LISTENing? - Mailing list pgsql-general

From Jasen Betts
Subject Re: Who is LISTENing?
Date
Msg-id k5jjbf$jk5$1@reversiblemaps.ath.cx
Whole thread Raw
In response to Who is LISTENing?  (rektide <rektide@voodoowarez.com>)
Responses Re: Who is LISTENing?  (Chris Travers <chris.travers@gmail.com>)
List pgsql-general
On 2012-10-15, rektide <rektide@voodoowarez.com> wrote:
> Hi pgsql-general,
>
> I'm interested in writing a supervisory process that can insure worker processes are
> running/spawn new ones if not. These workers will mainly be responsible for LISTENing to
> the db, which is emitting triggered_change_notification s.
>
> Is there any means to check a NOTIFY queue to see who or if anyone is LISTEN ing on it?
>

Notifies are not reliable, what I mean is they are "best effort"
this is unlike the other things postgres does, there's no guarantee
that you'll get the message, for example the network might go down at
the same time as the notifiy is emitted, if that happenss a listening
client would miss the notify message and by the time it reconnects the
message is gone.

If you need reliable mesaging use a mesage queue in a table:
Emit a notify when you insert into the queue and the listeners can check
the queue when they connect, and again after each notify.

OTOH, if best effort is good enough,  the table pg_stat_activity will give
you the username of each connected client. perhaps ypu can infer from that
who was probably listening when you last checked...



--
⚂⚃ 100% natural

pgsql-general by date:

Previous
From: Ryan Kelly
Date:
Subject: Re: Strategies/Best Practises Handling Large Tables
Next
From: madhukiranj
Date:
Subject: Re: transitive pruning optimization on the right side of a join for partition tables