Topics
Topics are another communication model that provide a publish/subscribe architecture pattern. This allows a message to be consumed by many subscribers, and each subscriber is able to process the message independently.
A Topic has similar characteristics to a Service Bus Queue. When you create a topic by code, you would normally use the NamespaceManager
class, as follows:
//create the token TokenProvider token = TokenProvider.CreateSharedSecretTokenProvider(name, key); //create the uri Uri uri = ServiceBusEnvironment.CreateServiceUri("sb", "mynamespace", string.Empty); //create a namespace instance NamespaceManager nsManager = new NamespaceManager(uri, token);
You then use the NamespaceManager
instance to create a Topic, just as you would when you create a Queue.
nsManager.CreateTopic("SalesTopicQueue");
Note
Note that you cannot use the same name for a Queue and Topic within the same namespace. This will cause a MessagingEntityAlreadyExists
exception to be thrown.
Once the Topic has...