Re: How about synchronous notifications?

From: Lincoln Yeoh <lyeoh(at)pop(dot)jaring(dot)my>
To: Vick Khera <vivek(at)khera(dot)org>, pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: How about synchronous notifications?
Date: 2010-09-22 13:53:51
Message-ID: 20100922135420.C257F133798F@mail.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

At 07:55 PM 9/22/2010, Vick Khera wrote:

>Here's how you do it: first, make sure you are not within a
>transaction or other Pg activity. Get the socket's file handle from
>the Pg connection handle. When you're ready to wait for a notify
>event, just do a select() system call on that file handle waiting
>until there is data to read on that socket.
>
>When you return from the select, just check for the notifications and
>you're ready to go. If you did not find a notification, return to the
>select() call. Of course, this assumes you've issued the necessary
>LISTEN command.
>
>This has worked for me (and is tested well) up thru Pg 8.3. I cannot
>imagine it would stop working as the wire line protocol doesn't really
>change.

How'd one get the socket file handle if using JDBC/ODBC? It seems
possible if using perl DBD-Pg, but I haven't tested that to see if
you can really get out of a transaction.

Given these issues I guess it would be easier to use a separate
messaging server (despite that still not being that easy :) ). This
would have the characteristic of not being DB specific, so apps
wouldn't be locked in to postgresql. Whether this is a benefit or not
depends on your POV ;).

Regards,
Link.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2010-09-22 14:28:41 Re: What's wrong with this query?
Previous Message Vick Khera 2010-09-22 12:02:33 Re: versioned pl/pgsql functions