What is an Azure Service Bus? A Cloud Messaging Service

What is an Azure Service Bus? A Cloud Messaging Service

10 Apr 2024
Intermediate
38.2K Views
16 min read
Learn via Video Course & by Doing Hands-on Labs

Azure Developer Certification Course (Az-204)

Azure Service Bus: An Overview

Azure Service Bus is a fully managed multi-tenant cloud messaging service (MAAS). It is a brokered messaging system. Through this Azure Tutorial, we'll explore more about What is a Service Bus in Azure?, Features and Services provided by Azure Service Bus. To make things easier for you, Scholar Hat brings a comprehensive skill-oriented Azure Certification to the nitty-gritty of the Azure.

What is a Service Bus?

Software applications have different components like front-end app, backend web services, schedulers etc. SOA (software-oriented architecture) proposes a design for software implementations where these components can communicate with each other by application components through a communication protocol over a network. These application components can be visualized as Service Bus. Applications and services can communicate with each other using messages via Service Bus. Message consists of two parts; message properties and message payload. Message properties is a dictionary of values against property keys. Message payload is in binary format, which can contain JSON, XML, or text data.

What is a Service Bus?Figure 1: SOA Components

Read More: Top 50 Azure Interview Questions and Answers

Architecture

Azure Service Bus offers three types of communication mechanisms; queues, topics and, relays.

  • Queues and Topics, facilitate one-directional communication. Messages will be stored until they are consumed. Each message in Queue is received by a single recipient. Topic can have multiple subscriptions for multiple receivers. Subscriptions can choose to receive messages based on parameters. Messages from Queues and Topics can be accessed using Service bus-defined messaging APIs or REST APIs. SDKs are also available for other languages.
  • Unlike Queues and Topics; Relays provide bi-directional communication and does not store messages.

To use these messaging services, user must create namespace under Azure subscription. A namespace can be visualized as a logical container for messaging components. Multiple Service Bus components (queues, topics and relays) can reside within a single namespace.

azure bus Architecture Figure 2: Architecture - System implementation using Azure Service Bus components

Why Service Bus

As Azure Service Bus is fully managed service, scaling and availability will be taken care by Azure team. It is integrated with other Azure services like, Event Grid, Logic Apps, Stream Analytics etc. Azure Service Bus provides reliable and secure asynchronous message communication platform along with facility of delayed processing of events or data. Shared Access Signatures (SAS), Role Based Access Control (RBAC) and Managed Service Identity (MSI) protocols are supported by it. Service Bus also supports client libraries for .NET, Java, JMS.

Read More: Microsoft Azure Certification

Service Bus Tiers with Features

Features of Service Bus are available in two tiers; Premium and Standard.

  1. Standard tier

    It can be used for initial development and QA environment deployments. Latency and throughput in Standard tier are variable, hence performance is not predictable. In built scaling is also not available and maximum message size is upto 256 kb.

  2. Premium tier

    It can be used for Production deployments. It provides high throughput and auto scaling for variable workloads. Maximum message size can be up to 1mb. Premium name spaces provides CPU and memory level isolation for resources. Performance of Premium tier resources at peak load is much faster than Standard ones.

Azure Service Bus Services

  1. Queues

    As name suggest, Queues messaging service offers First In First Out data delivery. It enables ordered handling of unbounded sequences of related messages. Message sessions is used to ensure a first-in, first-out (FIFO). Queues enable us to store messages until the receiving application is available to receive and process them. Messages in queues are timestamped on arrival and ordered according to it. Messages are delivered on request (Pull mode delivery). Queue is often used for point-to-point communication.

    Messages from a Service Bus queue can be deleted immediately after reading. But if receiver app fails while processing then that message is lost. To avoid this situation, we can go for Peek Lock option. After receiving, it makes message invisible/locked for other receivers. If receiver processes message successfully, it will invoke Complete() function and message will be removed from queue. If receiver fails to process or does not respond within specified time interval, Abandon() function will be invoked and message will be available for other receivers.

    Lets take an example, where people are ordering food from online website application. When user done with ordering, message with order menu will be pushed into Queue by application. Order processing application will consume messages from Queue and process it one by one for delivery. Here food order must be processed in sequence. Hence, Queue is perfect option to choose.

    Azure Service Bus Services Figure 3: Food delivery app architecture using Service Bus Queue
  2. Topics

    Topics is nothing but single input queue but multiple output queues. Output queues are nothing but Subscriptions. Receiving apps needs to create subscriptions to receive messages from Topic. Subscription can filter out the messages based on rules on message properties. Publish/subscribe scenarios can be implemented using Topics.

    Let us use same example, which we have discussed above. Now we require high throughput while processing incoming orders. Here we can add multiple order processing applications, which will be reading same message queue. It is not possible to have multiple receivers for a Queue. Hence, we will create different subscriptions based on restaurant selected in order and process them differently. Subscription will filter the messages from Topic by restaurant name. Each order processing application will read message from respective subscription.

    Figure 4: Food delivery app architecture using Service Bus Topic and Subscriptions Figure 4: Food delivery app architecture using Service Bus Topic and Subscriptions
  3. Relays

    Queues and Topics provides unidirectional messaging. To facilitate bi-directional communication, Azure provides Relay messaging service. In Queues or Topics there is no explicit connection between sender and receiver. However, for relays, each application will create outbound TCP connection to Service Bus. All communication happens using WCF (Windows communication Foundation).

    We do not need to create relays explicitly. Relay will be created when application established connection to Service Bus. Idea of providing Relay method is to connect applications irrespective of their deployment environment. Some of the applications are deployed to different on premise data centers. To connect these applications for communication is not trivial task of development as well as configuration. To provide direct communication between applications without much effort, we can go for Azure Service Bus Relays.

    Figure 5: System Block diagram using Service Bus Relay Figure 5: System Block diagram using Service Bus Relay

Service Bus Queues vs Storage Queues

Azure supports two types of queue mechanisms: Storage queues and Service Bus queues. Storage queues are part of the Azure storage and Service Bus queues are part of Azure messaging infrastructure.

Similarities

  • Both guarantee At-least-once delivery of message.

  • We can receive messages in batch from both the services.

  • Both supports In-place update of messages.

Differences

  • Service Bus queues guarantee ordered delivery of messages (timestamp based) using message session.

  • Service Bus Queue allows batched send of messages.

  • State can be managed in Service Bus Queue messaging.

  • You can create unlimited number of Storage Queues, but 10k Service Bus per namespace queues.

  • Service Bus Queue supports Automatic dead lettering for messages that cannot be processed or delivered.

  • In Storage Queues, lock timeout can be applied at message level; in Service Bus it is applied at Queue level.

Service Bus Queues vs Topics

Similarities

  • Supports unidirectional communication.

  • Supports FIFO message delivery.

Differences

  • Queues can be used for one to one communication but Topics can be used for one to many communication scenario.

  • Receivers needs to subscribe for topics and optionally needs to specify rules.

Summary

Service Bus Messaging service has a lot to offer, we cannot cover its all capabilities in single article. There are Paired Namespaces, AMQP support, Partitioned Queues and many more. In short, Azure Service Bus helps us to build our loosely coupled software components with less deployment efforts and with high Scalability and Availability of communication. By providing three different types of services, it enables architect/developer to implement different communication scenarios.

ScholarHat Azure online training is delivered by Microsoft MVP Mr Shailendra to help you earn azure real-time focused Hand's-on skills and get azure certification

FAQs

Q1. What is the difference between a Service Bus and a message broker?

A message broker being a broader concept contain many middleware technologies that help in communication between different systems whereas a service bus focuses more on message delivery and queuing between application and the user.

Q2. Which messaging patterns are supported by Azure Service Bus?

The several messaging patterns supported in Azure Service Bus include:
  1. Point-to-Point
  2. Publish-Subscribe
  3. Request-Reply
  4. Scheduled
  5. Session-Based

Q3. What is the equivalent of Azure Service Bus?

Other messaging middleware alternatives for Azure Service Bus include services like Amazon Web Services, Google Cloud Platform, IBM Cloud, etc

Q4. What is Azure Service Bus vs Kafka?

Azure Service Bus is a messaging service managed by Microsoft Azure while Apache Kafka is a distributed streaming platform used for real time analytics and event sourcing.

Take our free azure skill challenge to evaluate your skill

In less than 5 minutes, with our skill challenge, you can identify your knowledge gaps and strengths in a given skill.

GET CHALLENGE

Share Article
Batches Schedule
About Author
Akshay S Deshmukh ( Author and Architect)

He is an Author, Architect and Optimist by choice. He has development experience in Azure, Microsoft Bot Framework, Angular and SharePoint. Strongly believe in "sharing is caring".
Self-paced Membership
  • 22+ Video Courses
  • 750+ Hands-On Labs
  • 300+ Quick Notes
  • 55+ Skill Tests
  • 45+ Interview Q&A Courses
  • 10+ Real-world Projects
  • Career Coaching Sessions
  • Email Support
Upto 60% OFF
Know More
Accept cookies & close this