Windows Azure Storage - Queues [0]!

OK, so let's get stuck into queues!

Queues in the Windows Azure Storage service provide reliable storage and delivery of messages.

There is no limit to the number of messages you can have in a queue, however in the current PDC release, any message older than 1 week will get cleaned up by the GC. Messages also cannot be bigger than 8kb, so if you need to queue something bigger than 8kb, store the primary object in a blob or table store, and use the queue message as a pointer to the Uri.

So what would you use a queue for? Well, as a start, they provide a great inter process communication (or inter-role communication) mechanism between web roles and worker roles.

You could have an interaction in your web role write a message to a queue, and have a worker role process that message asynchronously. Classic example is in a lead management system, you don't want the UI blocking while the lead is processed (as CRM systems are updated, emails sent, etc), so instead, you journal the lead in a queue, say thank you to the customer, and process the lead at your leisure.

What can you do with queues? Well, you can create, clear or delete a queue, or check it's length. For messages, you can enqueue them, dequeue them, or delete them. What's the difference between dequeue and delete? Well, let's look at a picture shall we?

image

As a starting point, I've created a little console app that creates a queue, adds some messages to it, then gets a bunch of messages and looks inside. Check out the code if your interested. You'll need:

1. SimpleQueueConsoleApp

2. Windows.Azure.Storage (this is my new and improved library for talking to the Storage Service, I'll complete the migration of the blob functionality in the New Year)

Enjoy :)