Example #1
0
        public async Task <ISendTransport> GetSendTransport(Uri address)
        {
            IServiceBusHost host = _hosts.FirstOrDefault(
                x => address.ToString().StartsWith(x.Settings.ServiceUri.ToString(), StringComparison.OrdinalIgnoreCase));

            if (host == null)
            {
                throw new EndpointNotFoundException("The endpoint address specified an unknown host: " + address);
            }

            var queueDescription = address.GetQueueDescription();

            var namespaceManager = await host.NamespaceManager;

            var namespacePath = namespaceManager.Address.AbsolutePath.Trim('/');

            if (IsInNamespace(queueDescription, namespacePath))
            {
                queueDescription.Path = queueDescription.Path.Replace(namespacePath, "").Trim('/');
                queueDescription      = await namespaceManager.CreateQueueSafeAsync(queueDescription);
            }
            else
            {
                namespaceManager = await host.RootNamespaceManager;

                queueDescription = await namespaceManager.CreateQueueSafeAsync(queueDescription);
            }

            MessagingFactory messagingFactory = await host.MessagingFactory;

            string queuePath = host.GetQueuePath(queueDescription);

            MessageSender messageSender = await messagingFactory.CreateMessageSenderAsync(queuePath);

            var sendTransport = new ServiceBusSendTransport(messageSender);

            return(sendTransport);
        }
Example #2
0
 public string GetQueuePath(QueueDescription queueDescription)
 {
     return(_host.GetQueuePath(queueDescription));
 }