You are viewing a free preview of this lesson.
Subscribe to unlock all 10 lessons in this course and every other course on LearningBro.
Azure Service Bus queues provide reliable, point-to-point message delivery between a sender and a receiver. They are the simplest messaging primitive in Service Bus and are ideal for decoupling services in distributed architectures. This lesson covers queue fundamentals, how messages flow through a queue, the receive modes, and practical considerations for building production systems.
A Service Bus queue is a durable, brokered message store. Messages are sent to the queue by one or more producers and consumed by one or more competing consumers. The queue guarantees:
Azure offers two queue services:
| Feature | Service Bus Queue | Azure Storage Queue |
|---|---|---|
| Protocol | AMQP 1.0, HTTP | HTTP |
| Max message size | 256 KB (Standard), 100 MB (Premium) | 64 KB |
| Ordering | FIFO guaranteed | Best-effort |
| Delivery | At-least-once, at-most-once | At-least-once |
| Dead-lettering | Yes | No |
| Transactions | Yes | No |
| Max queue size | 1 GB – 80 GB | 500 TB |
Use Service Bus queues when you need ordering, transactions, dead-lettering, or enterprise-grade reliability. Use Storage queues for simple, high-volume scenarios where individual message size is small and you do not need advanced features.
Before you can send or receive messages, you need a Service Bus namespace — a container for queues, topics, and subscriptions.
# Create a resource group
az group create --name rg-messaging --location uksouth
# Create a Service Bus namespace (Standard tier)
az servicebus namespace create \
--name sb-demo-ns \
--resource-group rg-messaging \
--sku Standard
# Create a queue
az servicebus queue create \
--name orders \
--namespace-name sb-demo-ns \
--resource-group rg-messaging
When creating a queue, you can configure:
| Property | Description | Default |
|---|---|---|
maxSizeInMegabytes | Maximum queue size (1024, 2048, 3072, 4096, 5120 MB for Standard) | 1024 MB |
defaultMessageTimeToLive | How long a message lives before expiring | 14 days |
lockDuration | How long a message is locked for a receiver in PeekLock mode | 30 seconds |
maxDeliveryCount | Number of delivery attempts before dead-lettering | 10 |
requiresDuplicateDetection | Enable duplicate detection | false |
deadLetteringOnMessageExpiration | Send expired messages to the dead-letter queue | false |
Messages are sent to a queue using a sender client. Each message has a body (the payload) and optional properties (metadata).
import { ServiceBusClient } from '@azure/service-bus';
const client = new ServiceBusClient(connectionString);
const sender = client.createSender('orders');
Subscribe to continue reading
Get full access to this lesson and all 10 lessons in this course.