Repository navigation
Description
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
- Start a DMLC with two absent queues and the default one consumer per queue. Both queues have a pending restart.
- Make
ConnectionFactory.createConnection()throwAmqpConnectExceptionorAmqpTimeoutException, then callsetConsumersPerQueue(2). The call throws and the configured count remains 1. - 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.
Activity
artembilan commentedon Oct 30, 2026
@sharanggupta, FYI.
Thanks
GH-3816: Keep DMLC restarts when adjusting fails
GH-3816: Keep DMLC restarts when adjusting fails
GH-3816: Keep DMLC restarts when adjusting fails