Subject Re: [Firebird-Java] Responding to Firebird events
Author Jim Starkey
S. Radojcin wrote:

> Hi,
> - I would like to respond on Firebird POST_EVENT (signaled from trigger
> or stored proc).
> For example, in my Java (web) application, I want to be notified when
> content of db table changes (in order to perform some action - let say
> ,reload db data)
>
> - Can someone tell me if this possible, and how ?
>
It rather means what you mean by possible. Can you do it now from
Java? No. Could Firebird events be supported in Java? Certainly,
though the asynchronous forms are incompatible with Java, the layered
synchronous call could. The real question whether it is a straight
forward extension to Jaybird.

The synchronous event call basically ssays, "Here's an encoded event
block of event names and event count thresholds. Return when any event
reaches the threshold with an updated event block." To be useful, the
synchronous call must be performed from a separate watcher thread. To
make the call, you need access to the database handle which is available
only inside of Jaybird, so a layered implementation is out of the question.

The complication is that Jaybird generally talks raw wire protocol to
the server, though it has facilities to do directly calls. While the
Firebird API is designed for remote/local transparency, there is a
modest bit of complication inside of the remote interface to make this
possible. In specific, on the first event calls, the server must create
a dedicated socket to return updated event blocks, and the remote
interface must be able to the networking handshake to connect to the new
server socket. It must also establish the necessary structures for
share this connection for subsequent calls and to tear it down when the
connection is closed, which makes connection pooling even more of a pain
that it is now. On the other hand, just about everything Firebird is
going to do in the future is going to make connection pool more
difficult, so we might as well just get used to this.

I'm willing to provide moral support, encouragement, and informations,
but I don't do LGPL or GPL, so I can't help with the actual code. If
you want to take this on, there is probably Software Hero, third rank,
status available for a successful implementation.