You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
PostgresSubscribableChannel calls a failing handler twice with the default retry template #11564
In what version(s) of Spring Integration are you seeing this issue?
7.0.x and 7.1.x (since 7.0.0), and main. 6.5.x is not affected.
Describe the bug
The default RetryTemplate in PostgresSubscribableChannel is built with RetryPolicy.builder().maxRetries(1). In the Spring Framework retry API maxRetries does not count the first call, so a handler that throws is invoked twice before the ErrorHandler gets the exception.
The reference manual says "By default, no retries are performed", and 6.5.x used RetryTemplate.builder().maxAttempts(1) from Spring Retry, which is one call in total. The value was carried over as is when the channel moved to the core retry API in GH-10345, where maxAttempts(1) already meant one retry, and it stayed 1 when the builder method was renamed to maxRetries.
Without a transaction manager the message is already removed from the table when the handler is called, so the second call repeats whatever the handler did before it failed.
To Reproduce
Subscribe a handler that always throws to a PostgresSubscribableChannel with no setRetryTemplate() and no transaction manager, set an ErrorHandler, and add one message to the group. The handler is called two times before the ErrorHandler runs.
Expected behavior
The handler is called once and the exception goes to the ErrorHandler, as documented.
Sample
I have a test for PostgresChannelMessageTableSubscriberTests that fails on main with expected: 1 but was: 2, and a fix that changes the default to maxRetries(0). I will open a PR with both.
Activity
GH-11564: No retries by default in `PostgresSubscribableChannel`
GH-11564: No retries by default in `PostgresSubscribableChannel`
GH-11564: No retries by default in `PostgresSubscribableChannel`