Re: A method to asynchronously LISTEN ?

From: Philippe Ebersohl <philippe(dot)ebersohl(at)dalim(dot)com>
To: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>, Dave Cramer <pg(at)fastcrypt(dot)com>
Cc: List <pgsql-jdbc(at)postgresql(dot)org>
Subject: Re: A method to asynchronously LISTEN ?
Date: 2019-02-27 10:47:48
Message-ID: 1000052273.5516163.1551264468429.JavaMail.zimbra@dalim.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

Hello,
I do not think there is a need for something like conn.listenSync().
We were just intrigued about the test.

In fact the current proposition should just work fine and we would like to test it.
How could we have access to a postgresql-*.jdbc.jar that includes this feature ?

Regards,
Philippe

From: "David G. Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: "Dave Cramer" <pg(at)fastcrypt(dot)com>
Cc: "Philippe Ebersohl" <philippe(dot)ebersohl(at)dalim(dot)com>, "List" <pgsql-jdbc(at)postgresql(dot)org>
Sent: Tuesday, 26 February, 2019 22:17:12
Subject: Re: A method to asynchronously LISTEN ?

On Tue, Feb 26, 2019 at 12:04 PM Dave Cramer < pg(at)fastcrypt(dot)com > wrote:

On Tue, 26 Feb 2019 at 12:29, David G. Johnston < david(dot)g(dot)johnston(at)gmail(dot)com > wrote:

BQ_BEGIN

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 ?

BQ_BEGIN

BQ_BEGIN

BQ_BEGIN

BQ_END

BQ_END

BQ_END

BQ_END

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.

In response to

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Dave Cramer 2019-02-27 10:53:59 Re: A method to asynchronously LISTEN ?
Previous Message David G. Johnston 2019-02-26 21:17:12 Re: A method to asynchronously LISTEN ?