implementing asynchronous notifications

From: Andras Kadinger <bandit(at)surfnonstop(dot)com>
To: pgsql-jdbc(at)postgresql(dot)org
Subject: implementing asynchronous notifications
Date: 2005-04-10 04:10:52
Message-ID: Pine.LNX.4.44.0504100511560.28671-100000@ns.surfnonstop.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

Greetings everyone,

A Java beginner here, seeking the insight of more experienced.

" A key limitation of the JDBC driver is that it cannot receive
asynchronous notifications and must poll the backend to check if any
notifications were issued." - http://jdbc.postgresql.org/documentation/80/listennotify.html

I am looking forward to have that limitation lifted.

When we are idle and not in a transaction, the backend actually sends us
notifications right away; in this case there is no need for us to do
polling with empty queries.

Under unix you can get the fd from libpq, select() on it, and then process
notifications by PQConsumeInput() and retrieve them with PQnotifies(). -
see last paragraph at
http://www.postgresql.org/docs/current/static/libpq-notify.html

Does Java provide working infrastucture to implement this reliably? What's
needed is a reliable way to detect that bytes have arrived on our
connection socket.

I am hoping java.net.Socket.getInputStream.available() could be used. Or
even better the new select()-like functionality provided by java.nio since
1.4. Do these actually work?

If java.nio does, would the impact of choosing java.nio, and thereby
excluding pre-1.4 platforms, an acceptable way of conduct? Or is there
infrastructure in the jdbc.postgresql.org project in place to allow us to
preserve backwards-compatibility by simply omitting this feature from
pre-1.4 builds?

Thank you in advance,

Best Regards,
Andras

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Oliver Jowett 2005-04-10 05:53:38 Re: implementing asynchronous notifications
Previous Message Pedro n/a 2005-04-09 02:18:42 FW: Re: Exception "The connection attempt failed." (didn't find anything