-
Notifications
You must be signed in to change notification settings - Fork 12
Configuration "TopicName"
What is a TopicName?
A TopicName, or as we will refer to it in the rest of this document as the Topic, is an endpoint that a subscription belongs too.
If you think of the Windows Azure Service Bus Namespace as a Class, a Topic would be like registering to a common event on the class.
Let's say you have a NewOrder message:
public class NewOrder {
public string OrderId {get;set}
public decimal Total {get;set;}
}
And you had a topic called Order. That topic would look like this if you were coding an event:
public class OrderTopic {
//When you create a subscription, it would be like created a new delegate against this event.
public event Action<NewOrder> NewOrderCreated;
//Calling this method is the same as Publishing a message to the Service Bus.
public static void NotifySubscribers(NewOrder order) {
if (NewOrderCreated != null) {
NewOrderCreated(order);
}
}
}
When you create a class that implements IHandleMessages, the framework will automatically create a unique subscription for you in the declared topic for the message NewOrder. When a publisher sends a message to the topic, this subscription will automatically get a copy.
[MessageHandlerConfiguration(
DeadLetterAfterMaxRetries=true,
MaxRetries = 2,
PauseTimeIfErrorWasThrown = 15000,
Singleton = true)]
public class TestMessageSubscriber : IHandleMessages<NewOrder> {
static Logger logger = LogManager.GetCurrentClassLogger();
public void Handle(IReceivedMessage<NewOrder> message) {
logger.Info("TestMessageSubscriber Message received: {0} {1}", message.Message.Value, message.Message.MessageId);
}
}
If you do not set the TopicName, every application that registers to the same Namespace will all be part of the same Topic.