Enterprise message broker for reliable asynchronous messaging. Service Bus offers:
- Queues: Point-to-point messaging, with FIFO ordering when you use sessions
- Topics & subscriptions: Publish-subscribe messaging patterns
- Sessions: Ordered message processing and correlation
- Dead-letter queues: Automatic handling of unprocessable messages
Azure Service Bus best practices
Several workers share one queue, each customer's messages stay in order, and a message that keeps failing is set aside instead of blocking the rest.
Competing consumers on a session queue
Queue orders
17·118·117·219·118·217·3
Session 17Session 18Session 19
Worker ASession 17✓ 0
Worker BSession 18✓ 0
Worker CSession 19✓ 0
Dead-letter queue
Six messages wait in the queue, grouped by session (one customer order each).
Illustrative exampleMessage properties & metadata
- ContentType: Specify message format (application/json, text/xml)
- CorrelationId: Correlate request and response messages
- SessionId: Group related messages for ordered processing
- MessageId: Unique identifier for deduplication
- Custom properties: Add application-specific metadata for filtering
Performance optimization
- Batch processing: Send/receive multiple messages in a single operation
- Prefetching: Client-side message caching for improved throughput
- Partitioning: Distribute messages across multiple message brokers (per entity in Basic and Standard, per namespace in Premium)
- Premium tier: Dedicated resources for predictable performance
- Message size: Keep messages small, use claim check pattern for large payloads
Advanced features
Message sessions
Guarantee FIFO processing for related messages. Use sessions for:
- Processing all messages for an order in sequence
- Implementing stateful message processing workflows
- Load balancing across multiple consumers while maintaining order
Scheduled messages
Enqueue messages to be available at a future time. Use cases:
- Delayed notification delivery
- Reminder systems and scheduled tasks
- Rate limiting with message spacing
Auto-forwarding
Chain queues and subscriptions for complex routing:
- Implement pipeline processing patterns
- Forward to another queue or topic in the same namespace (Standard and Premium tiers, up to four hops)
- Dead-letter queue consolidation