Skip Navigation LinksAzure Developers Guide > Azure Service Bus > Brokered Messaging > Using Topics and Subscriptions > Topics and Subscriptions

Training Courses

All course material is in English, and courses are delivered in English. Feel free to contact me for further information. cloudcasts.net@gmail.com

Topics and Subscriptions

In Service Bus brokered messaging, topics and subscriptions are used to implement publish subscribe channels.

TopicSubscription.png

 

Topics

Topics are similar to the enqueueing end of a queue. Applications send messages to topics in exactly the same way that they send them to queues by using a MessageSender object. Topics provide no interface for dequeuing messages, instead they have a collection of zero or more subscriptions that will subscribe to the messages sent to the topic based on filter rules. Topics provide support for message expiration, deadlettering and duplicate detection. The techniques for sending messages to queues can be used to send messages to topics. These are discussed in the Sending Messages section of Using Queues.

Subscriptions

Subscriptions are similar to the dequeuing end of a queue. Applications receive messages from subscriptions in exactly the same way that they receive them from queues by using a QueueClient or MessageSession object. A topic can have zero or more subscriptions, but a subscription can only belong to one topic. Subscriptions provide no external interface for enqueueing messages, internally messages are enqueued on the subscription inside the publish-subscribe channel based on routing logic in the subscription filters.

Subscriptions provide support for message expiration, dead lettering and message sessions. As topics provide support for duplicate message detection there is no need for this to be implemented on subscriptions as any duplicate messages should be detected by the topic before reaching the subscription. The techniques for receiving messages from queues can be used to receive messages from subscriptions. These are discussed in the Receiving Messages section of Using Queues.

Filter Expressions

Filter expressions are used to determine which of the messages sent to the topic the subscription will subscribe to. There are currently four types of filter that can be added to a subscription.

·        SqlFilter – Subscribes to messages based on a T-SQL like expression based using values in the message property dictionary

·        CorrelationFilter – Subscribes to messages based on the value of the CorrelationId property of the message

·        True Filter– Messages are always subscribed to

·        False Filter – Messages are never subscribed to

Speaking Engagements