letsc
letsc

Reputation: 2567

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?

Upvotes: 10

Views: 18982

Answers (1)

Gabriele Santomaggio
Gabriele Santomaggio

Reputation: 22750

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.

Upvotes: 10

Related Questions