Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rabbitmq - queues state shows as 'running' , GUI shows status as IDLE

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. queue status 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?

like image 546
letsc Avatar asked Jun 24 '15 22:06

letsc


People also ask

What is idle state in RabbitMQ?

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.

Why RabbitMQ shows activity on message rates but not on queued messages?

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.

How do I know if my RabbitMQ queue is empty?

$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.


1 Answers

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.

like image 184
Gabriele Santomaggio Avatar answered Sep 27 '22 19:09

Gabriele Santomaggio