In this article, we will discuss What are Azure service bus queues and how to use Azure service bus queues in real-time. Along with that, we will discuss a few other topics as mentioned below.
Table of Contents
What are Azure Service bus Queues?
Queues are the main concepts of Azure Service Bus.
Azure Service bus Queues are part of the Azure messaging service that supports queueing mechanisms. Messages will be in a queue and then will be processed with the First-in-first-out mechanism.
Note that Azure Service bus Queues are different than Azure Storage Queues. You can check out Azure Storage Queue vs Service Bus to know the key differences between both of them.
How to use Azure Service bus Queues
To use the Azure Service bus Queues we need to perform the below steps.
- Create Azure Service bus namespace
- Creating a Queue in the Service bus namespace
- Sending a message to the Queue
- Peeking a message from the Queue
- Receiving a message from the Queue
Now, to use the Azure Service bus Queues, the first thing we need to create the Azure Service bus namespace.
Related: Azure service bus pricing
How to create Azure Service bus namespace
Well, it is so simple to create an Azure Service bus namespace in Azure Portal using the below steps.
- Log in to the Azure Portal.
- Search for Service bus and click on the search result Service Bus under Services.
3. Click on the + Create button on the Service Bus page or you can click on the Create service bus namespace button to create a service bus namespace.
4. On the Create namespace page, select the Basics tab and then provide the below details
- Subscription: Select a valid Azure Subscription.
- Resource Group: Click on the Create new link to create a new Resource Group or you can select an existing Resource Group.
- Namespace name: Provide a unique name for your Service bus namespace.
- Location: Choose the location or Region,
- Pricing tier: Choose the Pricing tier based on your requirement, You can click on the “Browse the available plans and their features” link to check out all the pricing tiers and then choose the one that best suits your requirement.
Leave all the values in the other tabs as it is and then click on the Review + Create button.
5. Now, the system will validate all the details entered by you, and then once all the details are valid, it will show you Validation Succeeded and the Create button will get enabled. Click on the Create button to create the Azure Service bus namespace.
6. Click on the Go to Resource button to navigate to the Azure Service bus namespace.
A namespace contains the Queues, So let’s create a Queue in the namespace.
Creating a Queue in the Service bus namespace
To create the queue in the Service bus namespace follow the below steps
7. On the Service Bus Namespace page, click on the + Queue button.
8. On the Create queue window, provide the below details.
- Name: Provide a unique name for the Queue.
- Max queue Size: Specify a max queue size.
- Max delivery count: Specify the maximum delivery count.
- Enable the other features like “Enable duplicate detection”, “Enable auto-delete on idle queue”, etc based on your requirement.
Finally, click on the Create button to create the queue inside the Service bus namespace.
9. To find the Queue you have created at the last step, Click on the Queues link from the left navigation on the Service Bus Namespace page.
Sending a message to the Queue
Now that our Queue is ready so as a next step, I will send a message to the Queue I have created.
10. Click on the Queue that we have created above.
11. On the Queue page, click on the Service Bus Explorer (Preview) from the left navigation –> Then click on the Send messages button as highlighted below.
12. On the Send messages window, Type a message in the Message Body, Choose a content type (For example text/plain) –> then click on the Send button.
Expand the Broker Properties, Specify a label or subject. You can also Specify the values for all other properties based on your need.
Finally, click on the Send button to send a message to the Service bus Queue.
Peeking a message from the Queue
13. On the Service Bus Queue page, select the Peek mode, Click peek from start or click on the Peek next messages to peek the next messages or even you can click on the Peek with options button.
Once, you will click on the Peek with options, on the Settings window, specify the number of messages to peek and the sequence number to peek from, and then click on the Peek button.
Receiving a message from the Queue
14. Now, the next job is to receive the message, So for that Select, the Receive mode, and click on the Receive messages button.
On the Settings window, Select Receive mode, Specify the number of messages to receive and specify the Max time to wait for a message in ms and then click on the Receive button, and you are done.
You may also like following the below articles
We have discussed What is Azure service bus queues, How to create Azure Service bus namespace, and how to use Azure service bus queues in real-time. Thanks for reading this article !!!
I am Rajkishore, and I have over 14 years of experience in Microsoft Azure and AWS, with good experience in Azure Functions, Storage, Virtual Machine, Logic Apps, PowerShell Commands, CLI Commands, Machine Learning, AI, Azure Cognitive Services, DevOps, etc. Not only that, I do have good real-time experience in designing and developing cloud-native data integrations on Azure or AWS, etc. I hope you will learn from these practical Azure tutorials. Read more.