You are viewing a free preview of this lesson.
Subscribe to unlock all 10 lessons in this course and every other course on LearningBro.
While queues deliver each message to a single consumer, Service Bus topics enable publish-subscribe patterns where a single message can be delivered to many consumers. Topics are essential for broadcasting events, notifications, and updates across multiple independent services. This lesson covers how topics and subscriptions work, how to use filters to route messages, and practical patterns for real-world systems.
A topic is similar to a queue in that it receives messages from senders. However, instead of delivering messages directly to consumers, the topic distributes copies of each message to one or more subscriptions. Each subscription behaves like a virtual queue that can have its own set of consumers.
+---> [ Subscription: billing ] ---> Billing Service
|
Producer --> [ Topic ] --+---> [ Subscription: audit ] ---> Audit Service
|
+---> [ Subscription: email ] ---> Email Service
Key characteristics:
# Create a topic
az servicebus topic create \
--name order-events \
--namespace-name sb-demo-ns \
--resource-group rg-messaging
# Create subscriptions
az servicebus topic subscription create \
--name billing \
--topic-name order-events \
--namespace-name sb-demo-ns \
--resource-group rg-messaging
az servicebus topic subscription create \
--name audit \
--topic-name order-events \
--namespace-name sb-demo-ns \
--resource-group rg-messaging
| Property | Description | Default |
|---|---|---|
maxSizeInMegabytes | Maximum topic size | 1024 MB |
defaultMessageTimeToLive | Default TTL for messages | 14 days |
requiresDuplicateDetection | Enable duplicate detection | false |
enablePartitioning | Partition across multiple message brokers | false |
| Property | Description | Default |
|---|---|---|
lockDuration | PeekLock duration | 30 seconds |
maxDeliveryCount | Attempts before dead-lettering | 10 |
deadLetteringOnFilterEvaluationExceptions | Dead-letter on filter errors | false |
autoDeleteOnIdle | Delete subscription after idle period | disabled |
By default, a subscription receives all messages sent to the topic. You can add filter rules so that a subscription only receives messages matching specific criteria.
Service Bus supports three types of filters:
A SQL-like expression evaluated against message properties:
az servicebus topic subscription rule create \
--name high-value-filter \
--subscription-name billing \
--topic-name order-events \
--namespace-name sb-demo-ns \
--resource-group rg-messaging \
--filter-sql-expression "amount > 100"
Subscribe to continue reading
Get full access to this lesson and all 10 lessons in this course.