X-Original-To: pgsql-jdbc-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id D29851FEED0D for ; Sun, 21 Aug 2005 13:44:27 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 52929-04 for ; Sun, 21 Aug 2005 16:44:21 +0000 (GMT) Received: from relais.videotron.ca (relais.videotron.ca [24.201.245.36]) by svr1.postgresql.org (Postfix) with ESMTP id C396A1FEECC2 for ; Sun, 21 Aug 2005 13:43:59 -0300 (ADT) Received: from [192.168.1.101] ([24.202.23.128]) by VL-MO-MR001.ip.videotron.ca (iPlanet Messaging Server 5.2 HotFix 1.21 (built Sep 8 2003)) with ESMTP id <0ILK00BNMZQVBL@VL-MO-MR001.ip.videotron.ca> for pgsql-jdbc@postgresql.org; Sun, 21 Aug 2005 12:42:32 -0400 (EDT) Date: Sun, 21 Aug 2005 12:43:38 -0400 From: David Gagnon Subject: Re: implementing asynchronous notifications PLEASE CONFIRM MY In-reply-to: <4266E296.6050105@opencloud.com> Cc: pgsql-jdbc@postgresql.org Message-id: <4308AF3A.2070400@siunik.com> MIME-version: 1.0 Content-type: multipart/alternative; boundary="Boundary_(ID_RYCw+KM0F/nXsh0eejZq2g)" X-Accept-Language: en-us, en User-Agent: Mozilla Thunderbird 1.0.2 (Windows/20050317) References: <4265A05C.6050302@opencloud.com> <42667C72.9070708@siunik.com> <4266E296.6050105@opencloud.com> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.298 required=5 tests=[AWL=-0.252, HTML_20_30=0.504, HTML_MESSAGE=0.001, HTML_TITLE_EMPTY=0.045] X-Spam-Level: X-Archive-Number: 200508/160 X-Sequence-Number: 13729 This is a multi-part message in MIME format. --Boundary_(ID_RYCw+KM0F/nXsh0eejZq2g) Content-type: text/plain; charset=ISO-8859-1; format=flowed Content-transfer-encoding: 7BIT Hi all, I have a java web application connected to a postgresql DB (of course :-)). I create a bunch of cache in my web Application and I need postgresql to inform the application of row update and delete. I think this is a common behavior when we cache data in the application and use stored procedure to update data. I saw this thread (See below) a while ago but I'm not sure a this is the best way to solve my problem. I think there is 3 possibilities to solve this problem: #1: Having rules/trigger on update and delete that create notification. On the java server I need a thread to read the notification and update the caches in the system accordingly. #2: Having rules/trigger on update and delete that write a line into a table. On the java server I need a thread to read the table and update the caches in the system accordingly. #3: Having rules/trigger on update and delete that call a CALLBACK function that goes directly to the server... and update the cache directly. #4: Any other idea ? For #1: Is that reliable? 100% full prove. I must not loose notifications... because my cache wont be in synch For #2: Seem the best way to do it... Is there a way to do it to reduce performance impact ? For #3: Don't think it's implemented yet ... am I wrong? Thanks for your help pointing me the best implementation to solve my problem Best Regards ! /David Oliver Jowett wrote: >David Gagnon wrote: > > > >> I just read this thread. Wich seems really interesting. Is there an >>example on how to use Async Notifies? I look at it a couple of months >>ago and found it not sufficient for my needs. I need to implement a >>notification mechanism to clear data from caches in my application on >>data update. >> >>Is this change allow me to do that .. ? That will be so nice :-) >> >>If yes it's that possible to get a small example on how to use it. >> >> > >Basically, you can now call PGConnection.getNotifications() and get >results without having to submit a dummy query first. > >You will still need an application-level loop that periodically calls >it, though. Also, it's not guaranteed to give you notifications: you >must be not in a transaction (this is server-side behaviour), and you >must be using a Socket implementation that implements available() (SSL >connections may not do this). > >-O > >---------------------------(end of broadcast)--------------------------- >TIP 2: you can get off all lists at once with the unregister command > (send "unregister YourEmailAddressHere" to majordomo@postgresql.org) > > > --Boundary_(ID_RYCw+KM0F/nXsh0eejZq2g) Content-type: text/html; charset=ISO-8859-1 Content-transfer-encoding: 7BIT Hi all,

  I have a java web application connected to a postgresql DB (of course :-)).  I create a bunch of cache in my web Application and I need postgresql to inform the application of row update and delete.  I think this is a common behavior when we cache data in the application and use stored procedure to update data. 

I saw this thread (See below) a while ago but I'm not sure a this is the best way to solve my problem.  I think there is 3 possibilities to solve this problem:

#1:  Having rules/trigger on update and delete that create notification.  On the java server I need a thread to read the notification and update the caches in the system accordingly.

#2: Having rules/trigger on update and delete that write a line into a table. On the java server I need a thread to read the table and update the caches in the system accordingly.

#3: Having rules/trigger on update and delete that call a CALLBACK function that goes directly to the server... and update the cache directly.

#4: Any other idea ?


For #1: Is that reliable? 100% full prove.  I must not loose notifications... because my cache wont be in synch

For #2:  Seem the best way to do it...  Is there a way to do it to reduce performance impact ?

For #3:  Don't think it's implemented yet ... am I wrong?


Thanks for your help pointing me the best implementation to solve my problem

Best Regards !

/David




Oliver Jowett wrote:
David Gagnon wrote:

  
 I just read this thread. Wich seems really interesting.  Is there an
example on how to use Async Notifies?  I look at it a couple of months
ago and found it not sufficient for my needs.  I need to implement a
notification mechanism to clear data from caches in my application on
data update.

Is this change allow me to do that .. ?  That will be so nice :-)

If yes it's that possible to get a small example on how to use it.
    

Basically, you can now call PGConnection.getNotifications() and get
results without having to submit a dummy query first.

You will still need an application-level loop that periodically calls
it, though. Also, it's not guaranteed to give you notifications: you
must be not in a transaction (this is server-side behaviour), and you
must be using a Socket implementation that implements available() (SSL
connections may not do this).

-O

---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
    (send "unregister YourEmailAddressHere" to majordomo@postgresql.org)

  

--Boundary_(ID_RYCw+KM0F/nXsh0eejZq2g)--