Re: NOTIFY - Mailing list pgsql-novice

From David G. Johnston
Subject Re: NOTIFY
Date
Msg-id CAKFQuwbLxck22uPwkUtRfq-O_SERm6hmOJ7=kcpNXeH5Gzfuxg@mail.gmail.com
Whole thread Raw
In response to NOTIFY  ("Greg Rychlewski (LCL)" <Greg.Rychlewski@loblaw.ca>)
Responses Re: [EXT] Re: NOTIFY  ("Greg Rychlewski (LCL)" <Greg.Rychlewski@loblaw.ca>)
List pgsql-novice
On Mon, Sep 28, 2020 at 3:35 PM Greg Rychlewski (LCL) <Greg.Rychlewski@loblaw.ca> wrote:

Hi,

 

I’m considering using NOTIFY to let my application react to changes in a table. If I only send the channel name without a payload, could I run into this issue:

 

  1. The table is updated and a notification is sent to my app
  2. My app reads the table, but hasn’t sent acknowledgement of the notification yet
  3. The table is updated again, but the notification gets dropped because it’s the same as (1), which hasn’t been acknowledged by the app

 

If this happened then there would be new data in my table but my app wouldn’t read it until the next time there was an update.


I don't understand where you are getting point 2 from - the pub/sub model doesn't require subscribers to acknowledge the notifications.

For point 3 you seem to have mis-read the NOTIFY documentation, which states:

"If the same channel name is signaled multiple times with identical payload strings within the same transaction, only one instance of the notification event is delivered to listeners."

The part about "within the same transaction" solves your concurrency concern, and doesn't say anything about acknowledgements.

David J.

pgsql-novice by date:

Previous
From: "Greg Rychlewski (LCL)"
Date:
Subject: NOTIFY
Next
From: "Greg Rychlewski (LCL)"
Date:
Subject: Re: [EXT] Re: NOTIFY