Skip to content

DMLC drops pending restarts when setConsumersPerQueue fails to connect #3816

Closed

Description

@BryanOnKeys

In what version(s) of Spring AMQP are you seeing this issue?

main at ef7eac870770fce8144367f52099a1ca3af5b0ee, including #3811.

Describe the bug

A connection failure during setConsumersPerQueue() can discard another configured queue's pending restart. After the connection and queues become available, that queue remains at zero consumers with no pending recovery.

adjustConsumers() clears the complete consumersToRestart set first. If the first createConnection() attempt throws, doConsumeFromQueue() queues that first consumer and rethrows. The adjustment exits before rebuilding the restart entries for the remaining queues.

This is a separate failure path from #3811: the missing-queue and successful-adjustment scenarios now pass.

To Reproduce

  1. Start a DMLC with two absent queues and the default one consumer per queue. Both queues have a pending restart.
  2. Make ConnectionFactory.createConnection() throw AmqpConnectException or AmqpTimeoutException, then call setConsumersPerQueue(2). The call throws and the configured count remains 1.
  3. Restore the connection, make both queues available, and run the monitor repeatedly.

Observed with the attached isolated execution of the actual container class:

Adjustment Expected consumers A / B Observed A / B Pending after recovery
None (control) 1 / 1 1 / 1 0
Successful (control) 2 / 2 2 / 2 0
Connection exception 1 / 1 1 / 0 0
Timeout exception 1 / 1 1 / 0 0

Expected behavior

After the setter fails, all previously configured queues should retain recovery at the original consumer count.

Sample

Run python run_reproducer.py with Python 3 and JDK 17 or newer (py run_reproducer.py on Windows). The ZIP includes the exact source snapshot, dependency checksums, runner, and observed output. It exits 1 when the two failure cases reproduce.

Validation: compiled the actual source against published Spring AMQP 4.2.0-RC1 / Spring 7.1.0-RC1 support JARs. The sample uses dynamic proxies for RabbitMQ interfaces and explicitly invokes captured monitor callbacks. All four original #3811 scenarios and both controls pass; the two failed-adjustment cases reproduce. No live-broker integration or full Gradle-suite result is claimed. Found during an AI-assisted review.

spring-dmlc-failed-adjustment-reproducer.zip

Activity

  1. artembilan commented on Oct 30, 2026

    @artembilan
    Member

    @sharanggupta, FYI.

    Thanks

  2. added this to the 4.2.0 milestone on Oct 30, 2026
  3. added a commit that references this issue on Oct 30, 2026
  4. added 2 commits that reference this issue on Oct 30, 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