public virtual IEnumerable <Type> CreateTopicsForPublisher(Type messageType, IMessageNameFormatter formatter) { NamespaceManager nm = _address.NamespaceManager; foreach (Type type in messageType.GetMessageTypes()) { string topic = formatter.GetMessageName(type).ToString(); /* * Type here is both the actual message type and its * interfaces. In RMQ we could bind the interface type * exchanges to the message type exchange, but because this * is azure service bus, we only have plain topics. * * This means that for a given subscribed message, we have to * subscribe also to all of its interfaces and their corresponding * topics. In this method, it means that we'll just create * ALL of the types' corresponding topics and publish to ALL of them. * * On the receiving side we'll have to de-duplicate * the received messages, potentially (unless we're subscribing only * to one of the interfaces that itself doesn't implement any interfaces). */ nm.CreateAsync(new TopicDescriptionImpl(topic)).Wait(); yield return(type); } }
public Task CreateQueue() { if (QueueDescription == null) { throw new InvalidOperationException("Cannot create queue is the endpoint address is not for a queue (but for a topic)"); } return(_nm.CreateAsync(QueueDescription)); }