[rabbitmq-discuss] Querying broker info like rabbitmqctl does?

Matt Pietrek mpietrek at skytap.com
Tue Oct 9 18:54:42 BST 2012

I've come across a situation that's semi-obvious in retrospect given what I
know of RabbitMQ, but nonetheless escaped me till now.

I've written a variety of automation code in Python using the rabbitmq
management API. Things like purging queues, dumping queue contents to
files, simulating broker failover, etc...

Today I created a situation where I knew that there was an unacknowledged
message in a queue, and I could observe that was the case via the Web UI.
However, my code was getting a value of '0' for the messages_unacknowledged
column from /api/queues.

I eventually figured out that my HTTP call occurred before the default five
second statistics database update. Thus, if I waited a few seconds before
issuing the call, I got back the expected value of '1'.

Now, some of my automation depends on the values I get from the HTTP API to
be correct "now", rather than behind by some non-trivial interval.

Now, I realize that this is an inherently racy circumstance. I'm just
trying to reduce the window as much as possible. As I see it, I have three

   - Crank up the default update interval, suppressing perf as I go to
   smaller intervals
   - Somehow query the broker in the same way that rabbitmqctl does. I
   assume this involves writing Erlang code, which I'd like to avoid for time
   - Call rabbitmqctl and capture/parse the output.

Again, I realize that any solution is inherently only a snapshot in time -
Thoughts on how to best achieve the most recently correct values, ideally
in Python and without learning Erlang? :-)


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/attachments/20121009/1e5f2501/attachment.htm>

More information about the rabbitmq-discuss mailing list