<br><br><div class="gmail_quote">On Tue, Mar 20, 2012 at 12:17 PM, Simon MacMullen <span dir="ltr"><<a href="mailto:simon@rabbitmq.com">simon@rabbitmq.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div><div></div><div class="h5">On 20/03/12 06:43, Gerolf Seitz wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
When passively declaring a queue, the returned consumer count is not the<br>
same as the consumer count via the management plugin / http API. Turns<br>
out, rabbitmq returns the number of consumers that are ready to receive<br>
a message.<br>
<br>
As an example: there are 5 (manually acknowledging) consumers, 3 of<br>
which have consumed a message from the queue, but have not sent an ACK<br>
for the respective messages to the broker. Declaring a queue now returns<br>
a declare-ok with consumer-count == 2, whereas I would have expected it<br>
to be 5.<br>
<br>
Looking at the rabbitmq-server code reveals that the "active consumer"<br>
part of the state is used for getting the next consumer for round robin<br>
delivery and returning the number of consumers as part of the declare-ok<br>
message.<br>
<br>
Since I don't suspect this to be an oversight but rather a conscious<br>
decision, I'm interested in the rationale behind it. I'm aware that<br>
changing the semantics at this point is probably not possible and I may<br>
have to resort to fetching the consumer count via the http api (which<br>
brings some organizational overhead).<br>
<br>
Can anybody shed some light on this?<br>
</blockquote>
<br></div></div>
Hi Gerolf.<br>
<br>
Yes, this is deliberate. Code archaeology yielded this:<br>
<br>
<a href="http://hg.rabbitmq.com/rabbitmq-server/rev/32e357ad03d6" target="_blank">http://hg.rabbitmq.com/<u></u>rabbitmq-server/rev/<u></u>32e357ad03d6</a><br>
<br>
"count queue consumers as required by the spec".<br>
<br>
The spec actually says:<br>
<br>
Reports the number of active consumers for the queue. Note that<br>
consumers can suspend activity (Channel.Flow) in which case they<br>
do not appear in this count.<br>
<br>
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"...<br>
<br>
Hmm. I'll have a think about this. What are you trying to do?<br>
<br>
Cheers, Simon<br><font color="#888888">
<br>
-- <br>
Simon MacMullen<br>
RabbitMQ, VMware<br>
</font></blockquote></div><div><br></div><div>The reply-to-author setting of rabbitmq-discuss screwed me ;)</div><div><br></div><div><br></div><div><br></div><span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)">Hi,</span><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)">
<br></div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)">The use case is this:<br><div><br></div><div>We have a pool of consumers (each running in a heavy weight process) that can only process a single unit of work at a time each.</div>
<div>The messages that are sent to these consumers contain data that can become "old" quite quickly (think stock ticks), so queuing hundreds of messages is not an option.</div><div>Also, these consumers need to be kept busy all the time: as soon as a unit of work is done, the next task will be submitted and picked up by the free consumer. (prefetch=1, autoack=false).</div>
<div><br></div><div>Based on the number of consumers, the system decides which unit of work is sent next, mostly based on the previous time the unit of work took to complete.</div><div><br></div><div>Example:</div><div>7 consumers overall</div>
<div>Per configuration, only up to 4 consumers may be used to process really long running tasks (eg. >1 minute task duration)</div><div>The rest of the consumers is used for short running tasks. (eg. <1 minute)</div>
<div><br></div><div>The reason why we don't have 2 different queues is twofold:</div><div>1) if there are no long running tasks to be executed, all consumers should be used for short running tasks</div><div>2) the decision whether a task is short or long running is made by the system that sends the messages to the broker and the decision process can be tweaked via configuration. This is easier to manipulate than reconfiguring and restarting the heavy weight consumer processes.<br clear="all">
<div><br></div><div>I hope this clears it up a bit ;)</div><div><br></div><div>Cheers</div></div></div><br clear="all"><div><br></div>-- <br><div>Gerolf Seitz</div><div><br></div><div>twitter: @gersei<div>code: <a href="http://github.com/gseitz" target="_blank">github.com/gseitz</a></div>
</div><div>blog: <a href="http://www.gerolfseitz.com" target="_blank">www.gerolfseitz.com</a></div><br>