Skip to content

PostgresSubscribableChannel initial message polling dies due to exception #8770

Closed
@joshiste

Description

@joshiste

Currently, on the first subscribe of a MessageHandler, notifyUpdate() is called to process messages already in the message store.
The problem with notifyUpdate() is that the try-catch block is outside the loop, so the loop will die on an exception, leaving further messages unprocessed.
When it receives notifications for inserted messages, this is not a problem because those notifications will submit a new task to poll further messages.

We could move the try-catch inside the loop to prevent it from dying. (If we don't do this, we might as well remove the try-catch, as it's good for nothing)
This would be fine for non-transactional usage. Messages are all processed and removed, and eventually, the loop stops.

This solution is a problem for transactional usage: The loop will never terminate, and the same message will be read repeatedly. For incoming notifications, we'd start further tasks that will go looping and exhaust the thread pool.
As of today, with transactional usage and without any other measures, messages producing an exception will also effectively block the channel (but not exhaust the thread pool)

Here is a reproducing test case and the mentioned solution. I'm not very lucky with that solution but currently have no better idea.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions