public inbox for [email protected]help / color / mirror / Atom feed
PGConnection.getNotifications(0) doesn't block 4+ messages / 2 participants [nested] [flat]
* PGConnection.getNotifications(0) doesn't block @ 2023-08-03 14:04 Pawel Veselov <[email protected]> 0 siblings, 2 replies; 4+ messages in thread From: Pawel Veselov @ 2023-08-03 14:04 UTC (permalink / raw) To: pgsql-jdbc Hello. I'm implementing a bit that is expected to wait for published channel notifications, and once there are any - process them. I'm using PGConnection.getNotifications(0), but that immediately returns an empty array, and doesn't block like JavaDoc says it should. I'm on 42.6.0. What am I missing? Thank you. ^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: PGConnection.getNotifications(0) doesn't block @ 2023-08-03 14:39 Pawel Veselov <[email protected]> parent: Pawel Veselov <[email protected]> 1 sibling, 0 replies; 4+ messages in thread From: Pawel Veselov @ 2023-08-03 14:39 UTC (permalink / raw) To: pgsql-jdbc Hello. On Thu, Aug 3, 2023 at 4:04 PM Pawel Veselov <[email protected]> wrote: > > Hello. > > I'm implementing a bit that is expected to wait for published channel > notifications, > and once there are any - process them. > > I'm using PGConnection.getNotifications(0), but that immediately > returns an empty > array, and doesn't block like JavaDoc says it should. > > I'm on 42.6.0. > > What am I missing? The transaction state is not IDLE, that's what's missing. But JavaDoc doesn't mention that bit. ^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: PGConnection.getNotifications(0) doesn't block @ 2023-08-04 08:47 rob stone <[email protected]> parent: Pawel Veselov <[email protected]> 1 sibling, 1 reply; 4+ messages in thread From: rob stone @ 2023-08-04 08:47 UTC (permalink / raw) To: Pawel Veselov <[email protected]>; pgsql-jdbc Hello, On Thu, 2023-08-03 at 16:04 +0200, Pawel Veselov wrote: > Hello. > > I'm implementing a bit that is expected to wait for published channel > notifications, > and once there are any - process them. > > I'm using PGConnection.getNotifications(0), but that immediately > returns an empty > array, and doesn't block like JavaDoc says it should. > > I'm on 42.6.0. > > What am I missing? > > Thank you. > > Have you read the JDBC docs https://jdbc.postgresql.org/documentation/server-prepare which has a section about Listen/Notify? HTH ^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: PGConnection.getNotifications(0) doesn't block @ 2023-08-04 09:49 Pawel Veselov <[email protected]> parent: rob stone <[email protected]> 0 siblings, 0 replies; 4+ messages in thread From: Pawel Veselov @ 2023-08-04 09:49 UTC (permalink / raw) To: rob stone <[email protected]>; +Cc: pgsql-jdbc > > I'm implementing a bit that is expected to wait for published channel > > notifications, > > and once there are any - process them. > > > > I'm using PGConnection.getNotifications(0), but that immediately > > returns an empty > > array, and doesn't block like JavaDoc says it should. > > > > I'm on 42.6.0. > > > > What am I missing? > > > > Thank you. > Have you read the JDBC docs > https://jdbc.postgresql.org/documentation/server-prepare > which has a section about Listen/Notify? I've read https://access.crunchydata.com/documentation/pgjdbc/42.1.1/listennotify.html instead. I've read the Listen/Notify section in https://jdbc.postgresql.org/documentation/server-prepare just now, which carries identical text. I've also read the JavaDocs for the method(s). All these sources agree or at least don't contradict that getNotifications(0) should block without conditions, and none mention that the connection must be in the IDLE transaction state. For that matter, even https://www.postgresql.org/docs/current/sql-listen.html doesn't say anything about the fact that notifications are only received/can be read if the connection is in that state. It only mentions that the transaction that executed LISTEN must be first committed for that connection to start seeing notifications (for subscribed channel). What I was effectively doing on that connection is: BEGIN LISTEN COMMIT BEGIN UPDATE xxx; <poll for notifications> I've created this for tracking: https://github.com/pgjdbc/pgjdbc/issues/2937 ^ permalink raw reply [nested|flat] 4+ messages in thread
end of thread, other threads:[~2023-08-04 09:49 UTC | newest] Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2023-08-03 14:04 PGConnection.getNotifications(0) doesn't block Pawel Veselov <[email protected]> 2023-08-03 14:39 ` Pawel Veselov <[email protected]> 2023-08-04 08:47 ` rob stone <[email protected]> 2023-08-04 09:49 ` Pawel Veselov <[email protected]>
This inbox is served by agora; see mirroring instructions for how to clone and mirror all data and code used for this inbox