RabbitMQ – Basic Queue Maintenance Notes
November 22, 2008
Here are some notes I have for maintaining RabbitMQ’s AMQP queues using the Erlang shell.
I am using (for demoing purposes) the RabbitMQ installation that came packaged with the On-Demand Elastic Server generated by CohesiveFT. It couldn’t have been any simpler.
To connect to the RabbitMQ Erlang node, you can pull it up through an SSH session into the Elastic Server (ES) itself or you can remotely connect to the Erlang node from your Erlang node. I will describe how to do both.
Connecting to Erlang from within the server:
sudo su - rabbitmq -s /bin/sh -c 'erl -sname foo -remsh rabbit@srabbitmq'
Connecting remotely to the RabbitMQ Erlang node:
There are a few ways to do this. Since this is just for minor maintenance work on my demo, I do not care about security (if I did, I would prefer setting up ~/.erlang.cookie); therefore, I will connect using the node’s cookie in the following manner:
erl -sname foo -setcookie SOMECOOKIE -remsh rabbit@srabbitmq
The cookie (SOMECOOKIE) is obtained by logging into the ES and running:
cat /var/lib/rabbitmq/.erlang.cookie
For connecting remotely from your Windows workstation, use werl instead of erl so that the -remsh option will work.
When connecting remotely, make sure that port 4369 is open on your ES’s firewall and that the port for the current Erlang session is open (an easy way to determine the port on the ES is by reading the firewall error messages in /var/log/messages for the denied port).
Queue Maintenance
%% "At the erlang prompt, type "rabbit_amqqueue:stat_all().", which will
%% produce a brief report on the status of the queues in the system. This
%% tells you how many there are, how many consumers are listening on each,
%% and how many messages are backlogged on each. There is no indication of
%% how many messages have been through the queues yet." - tonyg
%% This example shows one queue, "my_topic_queue", with a single consumer
%% attached without any messages waiting to be consumed.
(rabbit@srabbitmq)1> rabbit_amqqueue:stat_all().
[{ok,{resource,<<"/">>,queue,<<"my_mytopic_queue">>},0,1}]
%% Specify the queue you want, and bind MyTopicQueue to it.
(rabbit@srabbitmq)2> {ok, MyTopicQueue, _, _ } = lists:nth(1, rabbit_amqqueue:stat_all()).
{ok,{resource,<<"/">>,queue,<<"my_mytopic_queue">>},0,1}
%% Lookup the queue and bind it to AMQ. We will purge this queue later.
(rabbit@srabbitmq)3> {ok, AMQ} = rabbit_amqqueue:lookup(MyTopicQueue).
{ok,{amqqueue,{resource,<<"/">>,queue,<<"my_mytopic_queue">>},
false,
true,
[],
[{binding_spec,{resource,<<"/">>,exchange,<<"my_topic_exch"...>>},
<<"US.#">>,
[]}],
<0.317.0>}}
%% Purge the queue
(rabbit@srabbitmq)4> rabbit_amqqueue:purge(AMQ).
{ok,0}
It’s been a while since I took these notes, so things may have changed since then. I just wanted to share my notes with anyone else starting out with RabbitMQ and also to record them on a public medium for when I may need to access them remotely. Please comment with any necessary corrections.
It’s also been a while (2 years) since my last post.
Page Title: A bookmark friendly format
December 6, 2006
Page titles are used as descriptors in (social) bookmarking. Consequently, a well formatted page title can speed up the process of finding a bookmark.
Here is the page title format that I find most effective to my bookmarking:
1. Page Name – Domain Name – Date
2. Page Name – Site Name – Date
I prefer domain name over site name, often because it’s usually shorter.
Date is only used when appropriate (blog, news, …). Ex: Dec 6, 2006
In or Out?
October 16, 2006
Is Eating Out Cheaper Than Eating In? I often revisit this question on a monthly basis (and its usually whenever the bills are due). I have always preferred eating out, because it’s quick. Other reasons include the fact that I do not enjoy left-overs and that I only cook for one person. So, I usually spend about $7-10 a meal when eating out. That’s almost $20 a day.
I found my most cost and time effective solution to be eating out for dinner and eating in (paper-bagging) for lunch. The reason being is that lunch requires very few ingredients that last for about a week. Specifically, breads and deli meats.
Though, I tend to do the opposite. I usually eat out for both lunch and dinner, but occasionally will cook dinner (such as pastas and some frozen meals). The reason I eat out for lunch is because I prefer social meals. Also, I can never remember to make my lunch the night before.
I wonder if frozen meals are healthier than eating out? They taste great and can be lighter on the wallet.
p.s. Eating out for me does not include any place that offers “super-sized” or “value menu” meals.
Threatening the President Online = Bad Idea
October 15, 2006
Teen questioned for online Bush threat.
I’m glad. Isn’t it terrorists who want to undermine the US Government and destroy American citizens?
Code Search
October 5, 2006
I’m not sure how long this has been out, but I just found Google’s Code Search today. Anyways, I found this search to be particularly entertaining (and scary).
Cursor Icon Confusion
October 4, 2006
I just visited Lefsetz Letter, where I noticed that they use the cross hair cursor for text selection instead of the I-bar cursor. This seems more logical to me, especially since the I-bar represents editable text and cross represents selection. So how did the I-bar become the standard. So, check out that website and let me know what you think of the cross hairs.
Is Mark Cuban Correct on YouTube
September 29, 2006
Read this:
The Coming Dramatic Decline of Youtube
Then this:
Watch Full Length Cartoons Online (Massive List)
Then this:
And more interestingly:
Update: It looks like Mark Cuban was wrong. Google is a powerhouse.
Social Problems for Social Sites
September 27, 2006
An author’s response to the loss of Digg’s “top user”:
This comes at a time when another popular social networking website, Facebook, is facing user rebellion. The democratic nature of social media is their biggest strength yet can also be their biggest problem. How should sites respond when their user base turns against them?
While this is a good observation, it’s really nothing new; word of mouth can make or break a product. But for this particular Digg user situation (and not speaking for the new algorithm)… I think they’ll be just fine.
The full article can be found here: Digg Changes Algorithm; Top User Resigns
p.s. If you are looking for a quick read on word of mouth marketing, I can recommend The Anatomy of Buzz: How to Create Word of Mouth Marketing by Emanuel Rosen.
November 19
September 14, 2006
…is when the Wii comes out!
“Listening To”?
September 8, 2006
Personal websites seem to be littered with music playlists and favorites. So, why is it that people like to list their music online? Is it because they want people to identify with them? Or is it because they like the music so much that they want to share this experience with others? Let me know what you think?
Here’s what I listen to (mwuahahaha): Led Zeppelin, Blind Melon, Talking Heads, Sound Tribe Sector 9, Medeski Martin & Wood, Disco Biscuits, Robert Randolph (& the Family Band), Sigur Ros, and AM radio.