Re: Java LISTEN/NOTIFY client library work-around

Lists: pgsql-hackerspgsql-jdbc
From: Joel Jacobson <joel(at)gluefinance(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Java LISTEN/NOTIFY client library work-around
Date: 2011-11-30 12:07:01
Message-ID: CA+9pJHR4SaDbxWGCJKVE0msH6sZKZbNKrzmpUrzjKPn5n9LV2A@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-jdbc

Hi,

As you know, LISTEN/NOTIFY is broken in the Java client library. You have
to do a SELECT 1 in a while-loop to receive the notifications.

http://jdbc.postgresql.org/documentation/head/listennotify.html

Is there some other library with a proper implementation where you don't
have to spam the database with queries to get the notifications?

If not, my company is willing to sponsor development of a patch fixing this
problem.

--
Best regards,

Joel Jacobson


From: Jan Urbański <wulczer(at)wulczer(dot)org>
To: Joel Jacobson <joel(at)gluefinance(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Java LISTEN/NOTIFY client library work-around
Date: 2011-11-30 12:27:19
Message-ID: 4ED62127.8050902@wulczer.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-jdbc

On 30/11/11 13:07, Joel Jacobson wrote:
> Hi,
>
> As you know, LISTEN/NOTIFY is broken in the Java client library. You have
> to do a SELECT 1 in a while-loop to receive the notifications.
>
> http://jdbc.postgresql.org/documentation/head/listennotify.html
>
> Is there some other library with a proper implementation where you don't
> have to spam the database with queries to get the notifications?

You mean a Java library? If Java is not a requirement, the psycopg2
Python library supports notifies well.

Cheers,
Jan


From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: Jan Urbański <wulczer(at)wulczer(dot)org>
Cc: Joel Jacobson <joel(at)gluefinance(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Java LISTEN/NOTIFY client library work-around
Date: 2011-11-30 13:58:04
Message-ID: 4ED6366C.7000602@dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-jdbc

On 11/30/2011 07:27 AM, Jan Urbański wrote:
> On 30/11/11 13:07, Joel Jacobson wrote:
>> Hi,
>>
>> As you know, LISTEN/NOTIFY is broken in the Java client library. You
>> have
>> to do a SELECT 1 in a while-loop to receive the notifications.
>>
>> http://jdbc.postgresql.org/documentation/head/listennotify.html
>>
>> Is there some other library with a proper implementation where you don't
>> have to spam the database with queries to get the notifications?
>
> You mean a Java library? If Java is not a requirement, the psycopg2
> Python library supports notifies well.
>
>

... and probably most libraries that (unlike JDBC) are libpq-based, like
the perl DBD::Pg.

cheers

andrew


From: Joel Jacobson <joel(at)gluefinance(dot)com>
To: Jan Urbański <wulczer(at)wulczer(dot)org>
Cc: "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Java LISTEN/NOTIFY client library work-around
Date: 2011-11-30 20:13:25
Message-ID: 357670BB-E029-4C33-AE60-5FFD5C9571A0@gluefinance.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-jdbc

On 30 nov 2011, at 13:27, Jan Urbański <wulczer(at)wulczer(dot)org> wrote:

> On 30/11/11 13:07, Joel Jacobson wrote:
>> Hi,
>>
>> As you know, LISTEN/NOTIFY is broken in the Java client library. You have
>> to do a SELECT 1 in a while-loop to receive the notifications.
>>
>> http://jdbc.postgresql.org/documentation/head/listennotify.html
>>
>> Is there some other library with a proper implementation where you don't
>> have to spam the database with queries to get the notifications?
>
> You mean a Java library? If Java is not a requirement, the psycopg2 Python library supports notifies

I need a Java-library for this

>
> Cheers,
> Jan


From: Kris Jurka <books(at)ejurka(dot)com>
To: Joel Jacobson <joel(at)gluefinance(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org, pgsql-jdbc(at)postgresql(dot)org
Subject: Re: Java LISTEN/NOTIFY client library work-around
Date: 2011-12-01 00:55:13
Message-ID: alpine.BSO.2.00.1111301949410.22157@leary.csoft.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-jdbc

On Wed, 30 Nov 2011, Joel Jacobson wrote:

> As you know, LISTEN/NOTIFY is broken in the Java client library. You have to
> do a SELECT 1 in a while-loop to receive the notifications.
>
> http://jdbc.postgresql.org/documentation/head/listennotify.html

This documentation is out of date. Currently you can get notifications
without polling the database if you are not using a SSL connection. You
still must poll the driver, using PGConnection.getNotifications, but it
will return new notifications received without an intermediate database
query. This doesn't work over SSL and potentially some other connection
types because it uses InputStream.available that not all
implementations support.

Kris Jurka


From: Joel Jacobson <joel(at)trustly(dot)com>
To: Kris Jurka <books(at)ejurka(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org, pgsql-jdbc(at)postgresql(dot)org
Subject: Re: Java LISTEN/NOTIFY client library work-around
Date: 2011-12-01 12:21:39
Message-ID: CA+9pJHQd+SL=N_yxicptJHKA7wcAhgFGE_QE5OdCL7WX-NSE2w@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-jdbc

2011/12/1 Kris Jurka <books(at)ejurka(dot)com>

>
>
> On Wed, 30 Nov 2011, Joel Jacobson wrote:
>
> > As you know, LISTEN/NOTIFY is broken in the Java client library. You
> have to
> > do a SELECT 1 in a while-loop to receive the notifications.
> >
> > http://jdbc.postgresql.org/documentation/head/listennotify.html
>
> This documentation is out of date. Currently you can get notifications
> without polling the database if you are not using a SSL connection. You
> still must poll the driver, using PGConnection.getNotifications, but it
> will return new notifications received without an intermediate database
> query. This doesn't work over SSL and potentially some other connection
> types because it uses InputStream.available that not all
> implementations support.
>

I know it works without SSL, but we need SSL for this.

If it would be possible to fix it, my company is as I said willing to pay
for the cost of such a patch.

>
> Kris Jurka
>

--
Joel Jacobson
Trustly
+46703603801
https://trustly.com


From: Merlin Moncure <mmoncure(at)gmail(dot)com>
To: Joel Jacobson <joel(at)trustly(dot)com>
Cc: Kris Jurka <books(at)ejurka(dot)com>, pgsql-hackers(at)postgresql(dot)org, pgsql-jdbc(at)postgresql(dot)org
Subject: Re: Java LISTEN/NOTIFY client library work-around
Date: 2011-12-02 16:16:17
Message-ID: CAHyXU0yi9qTTvw32jE9G=+Hzt9VD5zs-21ny78dn6Kc5sL4wTw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-jdbc

On Thu, Dec 1, 2011 at 6:21 AM, Joel Jacobson <joel(at)trustly(dot)com> wrote:
> 2011/12/1 Kris Jurka <books(at)ejurka(dot)com>
>>
>>
>>
>> On Wed, 30 Nov 2011, Joel Jacobson wrote:
>>
>> > As you know, LISTEN/NOTIFY is broken in the Java client library. You
>> > have to
>> > do a SELECT 1 in a while-loop to receive the notifications.
>> >
>> > http://jdbc.postgresql.org/documentation/head/listennotify.html
>>
>> This documentation is out of date.  Currently you can get notifications
>> without polling the database if you are not using a SSL connection.  You
>> still must poll the driver, using PGConnection.getNotifications, but it
>> will return new notifications received without an intermediate database
>> query.  This doesn't work over SSL and potentially some other connection
>> types because it uses InputStream.available that not all
>> implementations support.
>
>
> I know it works without SSL, but we need SSL for this.
>
> If it would be possible to fix it, my company is as I said willing to pay
> for the cost of such a patch.

I certainly don't want to discourage you from cleaning up the jdbc ssl
situation, but one workaround might be to use stunnel.

merlin