Re: A method to asynchronously LISTEN ? - Mailing list pgsql-jdbc

From David G. Johnston
Subject Re: A method to asynchronously LISTEN ?
Date
Msg-id CAKFQuwb_32MwN6SkMW=3pLQ=Y2e7zhteUsGJPvm_um0PCp+gAw@mail.gmail.com
Whole thread Raw
In response to Re: A method to asynchronously LISTEN ?  (Dave Cramer <pg@fastcrypt.com>)
Responses Re: A method to asynchronously LISTEN ?
List pgsql-jdbc
On Tue, Feb 26, 2019 at 12:04 PM Dave Cramer <pg@fastcrypt.com> wrote:


On Tue, 26 Feb 2019 at 12:29, David G. Johnston <david.g.johnston@gmail.com> wrote:
The question being asked is whether executeUpdate method performs synchronous execution of the listener function queue during its execution.

This after sending the command to the server and the server completing execution of the NOTIFY.  This assumes that the server places the notification on the channel for pick-up immediately (which will not be the case within a transaction).

While the client is, IIRC, synchronous, thus the local order of operations can be controlled, the server is asynchronous and thus this test is exposed to timing issues.  Maybe we need something like conn.listenSync() that blocks until a notification payload is received on the connection...?

kind of defeats the asynchronous aspect, no ?


You'd still want an asynchronous API for people but JavaScript introduced the "async/await" feature for a reason.  In this case making it "sync" instead of coding up wait loop seems desirable.  That said its quite possible I'm missing some existing feature as I haven't used this API at all.

David J.

pgsql-jdbc by date:

Previous
From: Dave Cramer
Date:
Subject: Re: A method to asynchronously LISTEN ?
Next
From: Philippe Ebersohl
Date:
Subject: Re: A method to asynchronously LISTEN ?