Re: one more question about LISTEN / NOTIFY - Mailing list pgsql-jdbc

From Craig Ringer
Subject Re: one more question about LISTEN / NOTIFY
Date
Msg-id 4C5E4419.7030009@postnewspapers.com.au
Whole thread Raw
In response to one more question about LISTEN / NOTIFY  (max <maxbox@directbox.com>)
List pgsql-jdbc
On 08/08/10 10:40, max wrote:
> Hello,
>
> I asked about the Listen / Notify commands some weeks ago. I decided to
> give it a trial.
> But I have one more question about it. What happens to notifications if
> the connection from a listener application disconnects unexpected. Does
> PostgreSQL store all notifications that are triggered during this period
> and submit it to the next listener that (re)connect? Or can I lose
> notifications if something unexpected happened with my connection?

You lose notifications during any period you don't have a connection.
Usually you'd be re-reading anything of interest from the database if
you have to reconnect, as any operation on the old connection would've
failed and you'd have to re-try your transaction. You'd be re-populating
any caches, etc.

In my own app, if I lose a connection I re-issue LISTEN s on any keys of
interest, *then* SELECT them to refresh the copies my app has in case
they've changed. If you're using listen/notify as a change notification
system that works great.

If you're trying to use listen/notify as a message queuing mechanism,
you should probably look at dedicated queuing systems. Building your own
queuing system is harder than you'd think, and listen/notify is not
particularly well suited to reliable message queuing.

--
Craig Ringer

pgsql-jdbc by date:

Previous
From: max
Date:
Subject: one more question about LISTEN / NOTIFY
Next
From: -
Date:
Subject: Java proxies connection to postgres