1 · Why Decouple with Queues
Direct synchronous calls between services create tight coupling, cascading failures, and uneven load. Queues solve three fundamental problems:
- Temporal decoupling — Producer and consumer don't need to be online simultaneously.
- Load leveling — Queues absorb traffic spikes; consumers process at their own pace.
- Competing consumers — Multiple workers pull from one queue, scaling throughput horizontally.
2 · Service Bus vs Storage Queues
| Criterion | Storage Queue | Service Bus Queue |
|---|---|---|
| Max message size | 64 KB | 256 KB (Std) / 100 MB (Premium) |
| Max queue size | 500 TB | 1–80 GB |
| Delivery guarantee | At-least-once | At-least-once or at-most-once |
| Ordering | Best-effort FIFO | FIFO via sessions |
| Dead-letter queue | No (use poison queue manually) | Built-in DLQ per queue/subscription |
| Duplicate detection | No | Yes (message ID window) |
| Transactions | No | Yes (send + complete atomically) |
| Pub/Sub (topics) | No | Yes |
| Cost | Very low (per operation) | Higher (per message + base fee) |
| Best for | Simple, high-volume, low-cost | Enterprise patterns, ordering, transactions |
Rule of thumb: If you need topics, sessions, DLQ, or transactions → Service Bus. If you need cheap, massive backlogs → Storage Queues.
3 · Service Bus Concepts
Queue (Point-to-Point)
Each message is delivered to exactly one competing consumer. Ideal for work distribution.
Topic / Subscriptions (Pub/Sub)
Each subscription gets its own copy of the message. SQL-like filters on subscriptions reduce noise.
Dead-Letter Queue (DLQ)
Every queue/subscription has a DLQ sub-queue. Messages land there after max delivery attempts or TTL expiry. Monitor DLQ depth as a health signal.
4 · Message Patterns
- Point-to-point — Single queue, competing consumers. Order processing, job dispatch.
- Publish/Subscribe — Topic + subscriptions. Event fan-out (order placed → billing, inventory, notification).
- Request-Reply — Sender sets
ReplyTo+CorrelationId; responder sends to reply queue. - Priority queues — Separate queues per priority; consumers poll high-priority first.
- Claim-check — Large payload in Blob Storage; message carries the blob URI.
5 · Reliability Features
- Duplicate detection — Deduplicates by
MessageIdwithin a configurable time window (up to 7 days). - Message deferral — Postpone processing; retrieve later by sequence number when ready.
- Scheduled delivery — Enqueue now, visible to consumers at a future UTC time.
- Transactions — Atomic send + complete across entities in the same namespace (via
ServiceBusTransactionGroup). - Auto-forwarding — Chain queues/subscriptions to build processing pipelines.
- Peek-lock vs Receive-and-Delete — Peek-lock gives at-least-once safety; Receive-and-Delete gives at-most-once speed.
6 · Service Bus Tiers
| Feature | Basic | Standard | Premium |
|---|---|---|---|
| Queues | ✔ | ✔ | ✔ |
| Topics/Subscriptions | ✘ | ✔ | ✔ |
| Message size | 256 KB | 256 KB | 100 MB |
| Transactions / Sessions | ✘ | ✔ | ✔ |
| VNet integration / Private Endpoint | ✘ | ✘ | ✔ |
| Dedicated capacity (MU) | ✘ | ✘ | ✔ (1–16 MU) |
| Geo-DR (metadata) | ✘ | ✘ | ✔ |
Choose Premium when you need network isolation (Private Link / VNet), predictable latency (no noisy neighbours), large messages, or Geo-DR pairing.
7 · Ordering & Sessions
Without sessions, Service Bus provides best-effort ordering. Enable sessions for guaranteed FIFO per session ID:
- Set
SessionIdon each message (e.g., order ID). - Consumer accepts a session — gets exclusive lock on all messages in that session.
- Multiple sessions can be processed in parallel by different consumers while preserving per-session order.
Partitioned queues spread load across message brokers for higher throughput, but ordering is only within a partition (use sessions to pin related messages).
🌍 Real-World Scenario
Order Processing Pipeline
An e-commerce platform receives 10 K orders/min during flash sales:
- Ingestion: Web API sends order messages to a Service Bus queue with
SessionId = orderIdfor FIFO per order. - Competing consumers: 8 worker instances process orders — each locks a session, ensuring one order isn't split across workers.
- Dead-letter handling: Messages failing 10 delivery attempts land in DLQ. An Azure Function monitors DLQ depth via metric alert and routes to a support dashboard.
- Poison message strategy: On 3rd retry, worker inspects the error; if data-quality issue, forwards to a "manual-review" queue; if transient, defers for re-processing in 60 s.
- Fan-out: After order confirmed, worker publishes an event to a "order-confirmed" topic → subscriptions for Billing, Inventory, and Notification services.
Result: Zero message loss during 50× traffic spikes, < 2 s median processing latency, clear observability on DLQ health.
🎯 Exam Tip
AZ-305 loves asking: "Which messaging service supports FIFO ordering, dead-letter queues, and transactional send?" — answer is always Service Bus (not Storage Queues, not Event Hubs). If the question mentions "sessions" or "exactly-once processing," think Service Bus Premium or Standard. If it says "millions of events per second with partitions," that's Event Hubs.
📝 Knowledge Check
1. A solution requires guaranteed FIFO ordering for messages belonging to the same customer. Which Service Bus feature provides this?
2. Which scenario is best suited to Azure Storage Queues instead of Service Bus?
3. What happens to a Service Bus message that exceeds the maximum delivery count?
4. An architect needs Service Bus with Private Endpoint integration and dedicated throughput. Which tier is required?