From: Craig Ringer <craig@postnewspapers.com.au>
To: max <maxbox@directbox.com>
Cc: pgsql-jdbc@postgresql.org
Subject: Re: one more question about LISTEN / NOTIFY
Date: Sun, 08 Aug 2010 13:43:53 +0800
Message-ID: <4C5E4419.7030009@postnewspapers.com.au> (raw)
In-Reply-To: <4C5E1919.1040009@directbox.com>
References: <4C5E1919.1040009@directbox.com>
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-jdbc@postgresql.org
Cc: craig@postnewspapers.com.au, maxbox@directbox.com
Subject: Re: one more question about LISTEN / NOTIFY
In-Reply-To: <4C5E4419.7030009@postnewspapers.com.au>
References: <4C5E1919.1040009@directbox.com> <4C5E4419.7030009@postnewspapers.com.au>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox