Skip to content

GH-8770: Add PostgresSubsChannel.errorHandler #8777

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 25, 2023

Conversation

artembilan
Copy link
Member

Fixes #8770

The problem with the PostgresSubscribableChannel.notifyUpdate() is that the try-catch block is outside the loop, so the loop will die on an exception, leaving further messages unprocessed.

  • Add ``PostgresSubscribableChannel.errorHandleroption to be invoked after aRetryTemplate` and for every failed message.
  • The askForMessage() new logic is to catch an exception on a message and call errorHandler returning a FALLBACK_STUB to continue an outer loop in the notifyUpdate()

Cherry-pick to 6.1.x & 6.0.x

Fixes spring-projects#8770

The problem with the `PostgresSubscribableChannel.notifyUpdate()` is that the try-catch block is outside the loop,
so the loop will die on an exception, leaving further messages unprocessed.

* Add ``PostgresSubscribableChannel.errorHandler` option to be invoked
after a `RetryTemplate` and for every failed message.
* The `askForMessage()` new logic is to catch an exception on a message and call `errorHandler`
returning a `FALLBACK_STUB` to continue an outer loop in the `notifyUpdate()`

**Cherry-pick to `6.1.x` & `6.0.x`**
});
}

private Optional<?> askForMessage() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These method names seem to be misleading; we are actually dispatching; maybe dispatchMessageIfPresent?

… to more specific `pollAndDispatchMessage()`
@garyrussell garyrussell merged commit 769367d into spring-projects:main Oct 25, 2023
garyrussell pushed a commit that referenced this pull request Oct 25, 2023
* GH-8770: Add `PostgresSubsChannel.errorHandler`

Fixes #8770

The problem with the `PostgresSubscribableChannel.notifyUpdate()` is that the try-catch block is outside the loop,
so the loop will die on an exception, leaving further messages unprocessed.

* Add ``PostgresSubscribableChannel.errorHandler` option to be invoked
after a `RetryTemplate` and for every failed message.
* The `askForMessage()` new logic is to catch an exception on a message and call `errorHandler`
returning a `FALLBACK_STUB` to continue an outer loop in the `notifyUpdate()`

**Cherry-pick to `6.1.x` & `6.0.x`**

* * Rename private `PostgresSubscribableChannel.askForMessage()` method to more specific `pollAndDispatchMessage()`
garyrussell pushed a commit that referenced this pull request Oct 25, 2023
* GH-8770: Add `PostgresSubsChannel.errorHandler`

Fixes #8770

The problem with the `PostgresSubscribableChannel.notifyUpdate()` is that the try-catch block is outside the loop,
so the loop will die on an exception, leaving further messages unprocessed.

* Add ``PostgresSubscribableChannel.errorHandler` option to be invoked
after a `RetryTemplate` and for every failed message.
* The `askForMessage()` new logic is to catch an exception on a message and call `errorHandler`
returning a `FALLBACK_STUB` to continue an outer loop in the `notifyUpdate()`

**Cherry-pick to `6.1.x` & `6.0.x`**

* * Rename private `PostgresSubscribableChannel.askForMessage()` method to more specific `pollAndDispatchMessage()`
@garyrussell
Copy link
Contributor

...and cherry-picked after resolving minor conflict.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

PostgresSubscribableChannel initial message polling dies due to exception
2 participants