Re: How about synchronous notifications?
От
Lincoln Yeoh
Тема
Re: How about synchronous notifications?
Дата
Msg-id
20100922135420.C257F133798F@mail.postgresql.org
Список
Дерево обсуждения
pg_notify but no pg_listen? "A.M." <agentm@themactionfaction.com>
Re: pg_notify but no pg_listen? Bruce Momjian <bruce@momjian.us>
Re: pg_notify but no pg_listen? Craig Ringer <craig@postnewspapers.com.au>
Re: pg_notify but no pg_listen? "A.M." <agentm@themactionfaction.com>
Re: pg_notify but no pg_listen? Craig Ringer <craig@postnewspapers.com.au>
How about synchronous notifications? Lincoln Yeoh <lyeoh@pop.jaring.my>
Re: How about synchronous notifications? Tom Lane <tgl@sss.pgh.pa.us>
Re: How about synchronous notifications? Merlin Moncure <mmoncure@gmail.com>
Re: How about synchronous notifications? Vick Khera <vivek@khera.org>
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.
В списке pgsql-general по дате отправления