Re: Who is LISTENing?

From: Chris Travers <chris(dot)travers(at)gmail(dot)com>
To: Jasen Betts <jasen(at)xnet(dot)co(dot)nz>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Who is LISTENing?
Date: 2012-10-16 13:29:09
Message-ID: CAKt_ZftQCqLypXYPPrN-4+vQZM47jKh+3m5rTWgqqbh2VVWxiQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Tue, Oct 16, 2012 at 5:18 AM, Jasen Betts <jasen(at)xnet(dot)co(dot)nz> wrote:

> On 2012-10-15, rektide <rektide(at)voodoowarez(dot)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...
>

One of the goals of pg_message_queue was to create a simple message queue
system with listen/notify support (which is missing in pgq btw). It is
designed to be reasonably reliable but is still relatively feature poor.
It will probably never be big and professional like pgq, but may be very
helpful in many cases nonetheless. http://pgxn.org/dist/pg_message_queue/

The basic idea is that it automates some of the basic bailing twine you
might want to create in such a solution. Future versions will have more
logging, anti-refutation controls, etc.

Note the way we addressed this problem was that listen/notify was optional.
An application could be run from cron once a day and process queued items,
or it could connect and wait for notifications.

As of 0.1, it supports payload types of text, xml, and bytea. More types
coming soon in 0.2.

I would be interested in feedback on this, and if anyone wants to
contribute, I certainly will be happy to facilitate.

Best Wishes,
Chris Travers

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Matthew Kappel 2012-10-16 15:23:43 PostgreSQL training recommendations?
Previous Message Merlin Moncure 2012-10-16 13:21:08 Re: Strategies/Best Practises Handling Large Tables