I was playing around the rabbitmq HTTP API and came across a weird scenario. When I look at my queues through the web interface, the status of both of them shows as IDLE. .
However when I use the HTTP API, the return for both the queue shows as 'running'. The code im using is below:
import requests
import json
uri = 'http://localhost:15672/api/queues'
r = requests.get(uri, auth=("guest","guest"))
parsed = json.loads(r.content)
#print json.dumps(parsed, indent=4)
for i in parsed:
print '{:<20} : {}'.format(i.get('name'), i.get('state'))
Output:
test queue : running
test2 : running
Can someone explain this behaviour to me?
This checks whether the RabbitMQ consumers for a queue have been active in the last 5 minutes. Consumers in an idle state are listening to the queue but are unable to process the messages on it.
In case RabbitMQ receive non-routable message it drop it. So while message was received, it was not queued. You may configure Alternate Exchanges to catch such messages.
$channel->basic_get(QUEUE_NAME, true); // the second arg is no_ack . The second argument marks that no acknowledgment is expected for that message. That is, you don't have to "flag" the message as read for RabbitMQ to confidently dequeue it. Excluding it (having it = false) results in not popping the top message.
Check the Management_console source code here: https://github.com/rabbitmq/rabbitmq-management/blob/master/priv/www/js/formatters.js#L479
function fmt_object_state(obj) {
if (obj.state == undefined) return '';
var colour = 'green';
var text = obj.state;
var explanation;
if (obj.idle_since !== undefined) {
colour = 'grey';
explanation = 'Idle since ' + obj.idle_since;
text = 'idle';
}
The console shows "idle" if the field idle_since
is not null.
If there is "traffic" in your queue you will have a json like that:
"policy":"",
"exclusive_consumer_tag":"",
"consumers":0,
"consumer_utilisation":"",
"memory":176456,
"recoverable_slaves":"",
"state":"running",
if the queue is in idle (without traffic) you will have a json like that:
"idle_since":"2015-06-25 10:15:07",
"consumer_utilisation":"",
"policy":"",
"exclusive_consumer_tag":"",
"consumers":0,
"recoverable_slaves":"",
"state":"running",
As you can see the field "idle_since"
is not null.
In both cases the queue is always in running
state.
In conclusion it is just a web-view formatting.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With