[rabbitmq-discuss] Active consumers in declare-ok is less than the actual number of consumers

Simon MacMullen simon at rabbitmq.com
Tue Mar 20 11:17:32 GMT 2012


On 20/03/12 06:43, Gerolf Seitz wrote:
> When passively declaring a queue, the returned consumer count is not the
> same as the consumer count via the management plugin / http API. Turns
> out, rabbitmq returns the number of consumers that are ready to receive
> a message.
>
> As an example: there are 5 (manually acknowledging) consumers, 3 of
> which have consumed a message from the queue, but have not sent an ACK
> for the respective messages to the broker. Declaring a queue now returns
> a declare-ok with consumer-count == 2, whereas I would have expected it
> to be 5.
>
> Looking at the rabbitmq-server code reveals that the "active consumer"
> part of the state is used for getting the next consumer for round robin
> delivery and returning the number of consumers as part of the declare-ok
> message.
>
> Since I don't suspect this to be an oversight but rather a conscious
> decision, I'm interested in the rationale behind it. I'm aware that
> changing the semantics at this point is probably not possible and I may
> have to resort to fetching the consumer count via the http api (which
> brings some organizational overhead).
>
> Can anybody shed some light on this?

Hi Gerolf.

Yes, this is deliberate. Code archaeology yielded this:

http://hg.rabbitmq.com/rabbitmq-server/rev/32e357ad03d6

"count queue consumers as required by the spec".

The spec actually says:

     Reports the number of active consumers for the queue. Note that
     consumers can  suspend activity (Channel.Flow) in which case they
     do not appear in this count.

So that is slightly ambiguous - we are excluding consumers that have 
issued channel.flow, but also those which are blocked due to qos / ack 
interaction. But those could easily be defined as "inactive"...

Hmm. I'll have a think about this. What are you trying to do?

Cheers, Simon

-- 
Simon MacMullen
RabbitMQ, VMware


More information about the rabbitmq-discuss mailing list