Is there a way to tell PG not to send messages after the one I acknowledged last ?
I understand that acknowledge is more an instruction for PG to clean the related WALs, but I was wondering if there is a way to tell postgres to stop sending me messages until I have acknowledged the one I am currently processing ?
I don't see a way. I think this package needs to expose the pg connection in the data event handler args. Without this, I don't see a way to control back pressure. With it, you can pause the connection's stream and flush the current message before taking on the next. This work would need to be done within the wal_sender_timeout to avoid a connection close. I wonder if we could also just make this lib pause the stream until acknowledge is called.
I ended up stopping the service and going back to listening mode on demand. It may not be the most efficient, but after conducting some tests, it does the job.
I wrote a blog post about my experiments