Skip site navigation (1) Skip section navigation (2)

Re: [INTERFACES] Using Postgres's NOTIFY/LISTEN

From: Peter T Mount <peter(at)retep(dot)org(dot)uk>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-interfaces <pgsql-interfaces(at)postgresql(dot)org>
Subject: Re: [INTERFACES] Using Postgres's NOTIFY/LISTEN
Date: 1998-12-02 18:49:25
Message-ID: Pine.LNX.4.04.9812021844280.682-100000@maidast.retep.org.uk (view raw or flat)
Thread:
Lists: pgsql-interfaces
On Wed, 2 Dec 1998, Tom Lane wrote:

> Peter T Mount <peter(at)retep(dot)org(dot)uk> writes:
> > On Wed, 2 Dec 1998, John Bosch wrote:
> >> I'm using Postgresql as the database for a Java application I am writing
> >> and would like to use the NOTIFY/LISTEN feature of Postgres.
> 
> > Ok, you've got me thinking... It shouldn't be too difficult to add NOTIFY
> > support. I'll have a look at it during this morning, and I'll get back to
> > you.
> 
> NOTIFY is no problem --- there's no particular reason not to issue
> NOTIFY as a plain SQL command.  It's the LISTEN side of things that
> will require some driver support.
> 
> Ideally, you'd like to be able to invoke an application-supplied
> callback routine asynchronously when a notify message arrives.
> I don't know enough about Java to know if it has a well-defined
> event loop mechanism, but if it does and your driver can cause events
> to be issued, you should be in fat city.

The 1.1 AWT uses a listener model for it's events. I was thinking of
creating an Interface that defines a method that is called when a notify
occurs. Then, the client can create a class that implements this
Interface, and simply calls an addListener() method in the driver. Then,
any notify's received will cause the listener to be called.

The client can then stop this with the removeListener() method.

> You might care to look at libpgtcl's listen support in 6.4 --- it
> automatically issues LISTEN and UNLISTEN commands when the application
> registers or deregisters a callback request.

I was thinking along those lines for the addListener() and
removeListener() methods.

So far, today has been hell at work (as usual, NT decides to commit
suicide), so I didn't get round to looking at this. I'll do that shortly.

-- 
       Peter T Mount peter(at)retep(dot)org(dot)uk
      Main Homepage: http://www.retep.org.uk
PostgreSQL JDBC Faq: http://www.retep.org.uk/postgres
 Java PDF Generator: http://www.retep.org.uk/pdf


In response to

Responses

pgsql-interfaces by date

Next:From: Jason BoxmanDate: 1998-12-02 20:48:12
Subject: Re: [ADMIN] Re:
Previous:From: Tom LaneDate: 1998-12-02 15:53:43
Subject: Re: [INTERFACES] Using Postgres's NOTIFY/LISTEN

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group