A few days ago I was working on Azure queues to pass a message from one role to another. While reading articles about queues, I came across two types of queues available in Windows Azure.
We will have a look at these topics here.
First, why do we require queues in Azure?
In my experience, I have used queues to perform some action or operation in one role depending on another role. Let me clarify that.
Suppose, I want to perform some action in the worker role like zipping a document depending on performing actions in the web role. So, then how do we do this?
In this case, we can use queues. From the worker role you can send messages and in the worker role that works as a background worker, you can fetch messages and do necessary tasks.
But, there two types of queues available; they are:
- Windows Azure Queues.
- Windows Azure Service Bus Queues.
When and which queue is to be used?
Windows Azure Queues
Windows Azure Queue Storage is a service for storing a large number of messages that can be accessed from anywhere using HTTP or HTTPS. A single message can be up to 64KB in size. So, a queue may contain millions of messages. It is basically a part of Windows Azure Storage and enabled with a REST based architecture.
Service Bus Queues
It is a part of the Windows Azure messaging infrastructure that supports queuing, publishing etc..
The Windows Azure Queues are suitable for:
- Windows Azure queues were introduced first. It is a dedicated storage mechanism built on top of the Windows Azure storage service for processing queues.
- When an application needs to store and send over 5GB worth of messages in a queue and where the lifetime of messages is shorter than 7 days.
- Whenever tracking of messages is required.
- Whenever server-side logs of all transactions is required.
The Service Bus Queues are suitable for:
- Service Bus Queues were introduced later with the latest release of Service Bus.
- It is built on the Brokered Messaging infrastructure.
- During full integration with WCF.
- Solution requires automatic duplicate detection.
- When the Time to live period exceeds more than 7 days.
- When messages are less than 256 KB.
- When Ordered delivery is required.
- Whenever the queue size will not go beyond 5 GB.
In my next article, we will discuss using queues in Windows Azure.