Q48. What is Azure Queue service?
As discussed in a previous question, Queues are an important part of an Azure cloud service application. Queue service is also a service like blob storage and Table storage service. This service enables us to store and retrieve messages.
A queue can store anything that can be serialized. Maximum message size is 64KB in size. A queue data structure is such that data can be retrieved in a First in First out (FIFO) fashion. A queue can contain millions of messages, however for a particular storage account the messages are limited by the size of the storage account, that is 500TB.
We can use REST protocol or Storage client libraries to work with queue service.
In a cloud service application, queues are used for communication between web roles and worker roles. Let us understand the usage of queue service with an Azure inventory application example.
Consider Azure Inventory application which contains web role to accept sales orders and worker role to process the order and persist order details into the azure table storage.
Web role is the front end and accepts order details and place them into the queue for further processing. A worker role continuously checks for messages in the queue. When it finds a message, that is the sales order, it processes the order. This is how the workload is divided between web role and worker role. This ensures that sales orders can be accepted without any delay providing a smooth user experience for the end user. This is how queue storage works. This is the basis on which we can build highly scalable applications in windows azure.
When working with queues, you should know about Lock timeout property of a message. This timeout property is the amount of time within which the message should be processed and deleted.
When we retrieve a message from the Queue, the message becomes invisible. By default, the time for processing and deleting is 30 seconds and the maximum time is 7 days. However, we can change this default behavior in the GetMessage method.
If for any reason the worker role is not able to process the message, after the timeout period, the message is visible to other worker roles.
Application code is responsible for processing the message and deleting the message. Otherwise, after timeout period, the message will be visible to other instances of worker roles.
A queue can store anything that can be serialized. Maximum message size is 64KB in size. A queue data structure is such that data can be retrieved in a First in First out (FIFO) fashion. A queue can contain millions of messages, however for a particular storage account the messages are limited by the size of the storage account, that is 500TB.
We can use REST protocol or Storage client libraries to work with queue service.
In a cloud service application, queues are used for communication between web roles and worker roles. Let us understand the usage of queue service with an Azure inventory application example.
Consider Azure Inventory application which contains web role to accept sales orders and worker role to process the order and persist order details into the azure table storage.
Web role is the front end and accepts order details and place them into the queue for further processing. A worker role continuously checks for messages in the queue. When it finds a message, that is the sales order, it processes the order. This is how the workload is divided between web role and worker role. This ensures that sales orders can be accepted without any delay providing a smooth user experience for the end user. This is how queue storage works. This is the basis on which we can build highly scalable applications in windows azure.
When working with queues, you should know about Lock timeout property of a message. This timeout property is the amount of time within which the message should be processed and deleted.
When we retrieve a message from the Queue, the message becomes invisible. By default, the time for processing and deleting is 30 seconds and the maximum time is 7 days. However, we can change this default behavior in the GetMessage method.
If for any reason the worker role is not able to process the message, after the timeout period, the message is visible to other worker roles.
Application code is responsible for processing the message and deleting the message. Otherwise, after timeout period, the message will be visible to other instances of worker roles.
See More Questions and Answers on - Azure Storage
- What is storage account?
- Why Azure storage?
- How many types of services does Azure storage service provide?
- What is blob storage?
- What is Azure table storage?
- Where does my storage account reside and how to choose its geographic location?
- Give an overview of the Azure standard storage account?
- Compare storage options in Azure storage services and amazon web services?
- On what factors does Azure storage billing depend?