Skip to content

PostgresSubscribableChannel calls a failing handler twice with the default retry template #11564

Closed

Description

@Tanishq-Choudhary

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

  1. added
    status: waiting-for-triage
    on Oct 21, 2026
  2. added this to the 7.2.0 milestone on Oct 21, 2026
  3. added and removed
    status: waiting-for-triage
    on Oct 21, 2026
  4. added a commit that references this issue on Oct 26, 2026
  5. added a commit that references this issue on Oct 26, 2026
  6. added a commit that references this issue on Oct 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions