Please enable Javascript for better experience...
Getting started with Azure Service Bus Queue - Configure and Send/Receive/Peek messages
By Rahul Kumar Jha | Jun 30, 2020 | In Articles | Total Views [ 2359 ]
Taged In
(0 Like)
Rate

In this article, you will learn configuring service bus queue in azure portal and sending, receiving and peeking messages. 

Introduction

In this article, you will learn configuring service bus queue in azure portal and sending, receiving and peeking messages. To start with, you just need an Azure portal subscription – Trial or Paid. We will go step-by-step.

Benefit of Service Bus Queue

In service bus queue, message stored in queue and both sender and receiver work separately with their own processing rate.

Steps to configure Service bus queue

Go to Azure portal and click on new resource.

01

Search for “Service Bus” and select service bus template.

02

Template to create Service bus opens up. Click on Create.

03

Now create namespace for service bus.

04

Your input will be go through validation process and input is validated.

05

Click “Create” to create this resource. Once deployment is completed, you will see this below dashboard.

06

Now click on “Queue” to create a service bus queue.

07

You can find this queue on dashboard as below.

08

Or you can click on “Queue” or “Topic from side navigation.

09

You will find overview of Queue with many other options. Now click on “Shared access policies” tab, you will find a predefined key “RootManageSharedAccessKey” with all policy selected i.e. managed, send and listen. Primary connection string can be used to connect service bus using Visual Studio.

10

Adding SAS policies (This is optional and not in picture)

Now click on this queue. Here you will find options to create shared access policies for send, listen and manage. Click on “Shared access policies” and click “Add”.

11

A screen will open having options to create SAS polies.

12

Here we created two policies i.e. for send and listen.

13

Sending/Receiving messages from Queue

Now click on “Service Bus Explorer” option.

14

Here you will see message summary – active, dead-lettered and scheduled each having message count. You will also see tabs like “Send”, “Receive” and “Peek” with “Send” as default selected.

To send message select content type (Text/Plain, Application/XML or Application/JSON) and type message. You can also add custom attribute to send in message. Click on “Send” button to send message.

15

Once you press send, you will notice that count of active message increase to 1. Now click on “Receive” tab to receive message. Receive message button will receive one message at a time and will delete message from queue after you receive it. Click on “Receive” to receive message.

“Receive performs a destructive read (ReceiveAndDelete) from Queue and the message received will be deleted from the Queue. Messages shown here are no longer stored.”

16

You will get a message that message will be deleted once you confirm, press “Yes” and continue.

17

You will get this screen. Here you can notice that active message count is 0 now. Below you can see message. Click on it to view the message.

18

I sent one more message of application/json format. Let see how it react.

19

Click on “Receive” to receive message.

20

You can also peek messages (upto 32 messages at a time) to see preview of messages. Here I sent 2 messages of different type and clicked on “Peek” to peek these message. Now I can view them one by one. I can also receive it when required.

21

Now let’s receive it. Please note that receive works on FIFO (First in First Out). I created a plain test message first and then json message, so message of sequence number 4 should be received first that is plain text message. Here notice that active message count decrease to 1 from 2 and you can see test message in right side pane.

22

Hope this is clear now. In the next article, we will try to implement this in C# code.

Share this

About the Author

Rahul Kumar Jha
Rahul Kumar Jha
Founder, Developer dotnet-concept.com

Public profile: user/profile/99900001


Has working experience in different phases of Software Development Life Cycle (SDLC) in CMS, Gaming, Health Care and Financial Services domain using Agile pattern. Working experience in Design patterns, ASP.NET, MVC, ANGULAR, ANGULAR JS, Windows application, WCF, ADO.NET, SQL Server and Test Driven Development (TDD) environment with JQuery, JavaScript, N-Unit, Entity Frameworks, LINQ, Code Refactoring and Business Objects Models.

User's Comments


 
Please SignUp/Login to comment...

Or comment as anonymous...
* Name
* Email ID
Comment
 
 
 
 
 
 
Sponsors