Skip to content

Fix consumer count for quorum queues in queue.declare#16185

Merged
kjnilsson merged 1 commit intomainfrom
qq-passive-delare-bug-fix
Apr 17, 2026
Merged

Fix consumer count for quorum queues in queue.declare#16185
kjnilsson merged 1 commit intomainfrom
qq-passive-delare-bug-fix

Conversation

@kjnilsson
Copy link
Copy Markdown
Contributor

Previously, rabbit_fifo_client:stat/2 incorrectly returned the number of checked out messages (num_checked_out) instead of the actual number of consumers (num_consumers). This caused queue.declare operations on quorum queues to return the unacknowledged message count in the consumer_count field rather than the true number of active consumers.

This commit:

  • Updates rabbit_fifo_client:stat/2 to correctly extract num_consumers from the ra machine overview.
  • Adds queue_declare_passive_consumer_count to quorum_queue_SUITE to verify that passive declares return the correct consumer count when subscribing and cancelling consumers.

Previously, `rabbit_fifo_client:stat/2` incorrectly returned the number
of checked out messages (`num_checked_out`) instead of the actual number
of consumers (`num_consumers`). This caused `queue.declare` operations
on quorum queues to return the unacknowledged message count in the
`consumer_count` field rather than the true number of active consumers.

This commit:
- Updates `rabbit_fifo_client:stat/2` to correctly extract `num_consumers`
  from the ra machine overview.
- Adds `queue_declare_passive_consumer_count` to `quorum_queue_SUITE` to
  verify that passive declares return the correct consumer count when
  subscribing and cancelling consumers.
@Gsantomaggio
Copy link
Copy Markdown
Member

It works correctly now, tested with:

 Environment environment = new AmqpEnvironmentBuilder()
                .build();
        Connection connection = environment.connectionBuilder().build();
        connection.management().queue("my_qq").quorum().queue().declare();

        for (int i = 0; i < 15; i++) {
            Consumer consumer = connection.consumerBuilder().queue("my_qq").messageHandler((context, message) -> {
                System.out.println("Received message: " + new String(message.body()));
            }).build();
        }
       Management.QueueInfo info = connection.management().queueInfo("my_qq");

       System.out.println("Consumer count " + info.consumerCount() );

out:

Consumer count 15

@kjnilsson kjnilsson added this to the 4.4.0 milestone Apr 17, 2026
@kjnilsson kjnilsson requested a review from Gsantomaggio April 17, 2026 08:18
@kjnilsson kjnilsson marked this pull request as ready for review April 17, 2026 08:19
@kjnilsson kjnilsson merged commit cc3ec75 into main Apr 17, 2026
189 checks passed
@kjnilsson kjnilsson deleted the qq-passive-delare-bug-fix branch April 17, 2026 08:37
kjnilsson added a commit that referenced this pull request Apr 17, 2026
Fix consumer count for quorum queues in queue.declare (backport #16185)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants