Java LISTEN/NOTIFY client library work-around

Поиск
Список
Период
Сортировка
Искать

Java LISTEN/NOTIFY client library work-around

От:
Joel Jacobson <joel@gluefinance.com>
Дата:
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.


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

Re: Java LISTEN/NOTIFY client library work-around

От:
Jan Urbański <wulczer@wulczer.org>
Дата:
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

Re: Java LISTEN/NOTIFY client library work-around

От:
Andrew Dunstan <andrew@dunslane.net>
Дата:


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

Re: Java LISTEN/NOTIFY client library work-around

От:
Joel Jacobson <joel@gluefinance.com>
Дата:
On 30 nov 2011, at 13:27, 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 

I need a Java-library for this

> 
> Cheers,
> Jan

Re: Java LISTEN/NOTIFY client library work-around

От:
Kris Jurka <books@ejurka.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.

Kris Jurka

Re: Java LISTEN/NOTIFY client library work-around

От:
Joel Jacobson <joel@trustly.com>
Дата:
2011/12/1 Kris Jurka <books@ejurka.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


Re: Java LISTEN/NOTIFY client library work-around

От:
Merlin Moncure <mmoncure@gmail.com>
Дата:
On Thu, Dec 1, 2011 at 6:21 AM, Joel Jacobson  wrote:
> 2011/12/1 Kris Jurka 
>>
>>
>>
>> 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
FAQ