Rackspace Cloudvent Calendar Day 9: Cloud Queues: You’ve Got Messages!

In the spirit of the holiday season, I’m sharing some tips and features of our cloud that you may not know about. In this countdown I’ll have 24 posts for you, each covering a single topic or feature about Rackspace Cloud products. We’ll post one per day so keep checking back!

Cloud Queues is  FREE to use until January, so now is a great time to try out this new product powered by the OpenStack Marconi project. You can use both Producer-Consumer and Publisher-Subscriber scenarios with a single API. In this post, let’s look at creating a queue and putting a message on that queue.

To create a queue you just need a name for your queue. We’ll call ours “vogon”:

curl –s –X PUT–H “X-Auth-Token: $TOKEN” https://ord.queues.api.rackspacecloud.com/v1/queues/vogon

Done! Now we have a Cloud Queue called “vogon” we can put messages on. Let’s add a message to the vogon queue (we can submit up to 10, but let’s just do one):

curl –s –X POST –d [{"ttl": 300, "body": {"client": "ArthurDent"}} –H “Content-type: application/json” –H “X-Auth-Token: $TOKEN” https://ord.queues.api.rackspacecloud.com/v1.0/queues/vogon/messages

Great! We have a message containing some information called ArthurDent in our Vogon queue.  To have our worker claim 10 messages from the queue, issue a POST request:

curl –s –X POST –H “X-Auth-Token: $TOKEN” https://ord.queues.api.rackspacecloud.com/v1/queues/vogon/claims?limit=10

You can claim up to 20 messages. When a worker finishes processing a message, it should delete the message before the claim expires to ensure that the message is processed only once.

For more information on Cloud Queues, check out our API documentation.


Please enter your comment!
Please enter your name here