Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id A01DC632903 for ; Sun, 8 Aug 2010 02:44:09 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024) with ESMTP id 21069-06 for ; Sun, 8 Aug 2010 05:44:02 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from www.postnewspapers.com.au (www.postnewspapers.com.au [202.4.227.11]) by mail.postgresql.org (Postfix) with ESMTP id 30EFD6328CA for ; Sun, 8 Aug 2010 02:44:02 -0300 (ADT) Received: from mail.postnewspapers.com.au (202-89-185-120.static.dsl.amnet.net.au [202.89.185.120]) by www.postnewspapers.com.au (Postfix) with ESMTP id A816B9F7E; Sun, 8 Aug 2010 13:43:36 +0800 (WST) Received: from localhost (localhost [127.0.0.1]) by mail.postnewspapers.com.au (Postfix) with ESMTP id D361AAED18; Sun, 8 Aug 2010 13:42:46 +0800 (WST) X-Virus-Scanned: Debian amavisd-new at postnewspapers.com.au Received: from mail.postnewspapers.com.au ([127.0.0.1]) by localhost (mail.postnewspapers.com.au [127.0.0.1]) (amavisd-new, port 10024) with LMTP id TxeUisZki1dv; Sun, 8 Aug 2010 13:42:41 +0800 (WST) Received: from [10.1.1.3] (124-169-225-224.dyn.iinet.net.au [124.169.225.224]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "Craig Ringer", Issuer "POST Certificate Authority" (verified OK)) by mail.postnewspapers.com.au (Postfix) with ESMTPSA id 92C4CAED12; Sun, 8 Aug 2010 13:42:41 +0800 (WST) Message-ID: <4C5E4419.7030009@postnewspapers.com.au> Date: Sun, 08 Aug 2010 13:43:53 +0800 From: Craig Ringer User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.9) Gecko/20100423 Lightning/1.0b1 Thunderbird/3.0.4 MIME-Version: 1.0 To: max CC: pgsql-jdbc@postgresql.org Subject: Re: one more question about LISTEN / NOTIFY References: <4C5E1919.1040009@directbox.com> In-Reply-To: <4C5E1919.1040009@directbox.com> X-Enigmail-Version: 1.0.1 Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-0.51 tagged_above=-10 required=5 tests=BAYES_05=-0.5, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201008/21 X-Sequence-Number: 20824 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