public Task <ISendTransport> GetSendTransport(Uri address) { IServiceBusHost host; if (!TryGetMatchingHost(address, out host)) { throw new EndpointNotFoundException("The endpoint address specified an unknown host: " + address); } return(host.RetryPolicy.Retry <ISendTransport>(async() => { QueueDescription queueDescription = address.GetQueueDescription(); string queuePath; string namespacePath = host.NamespaceManager.Address.AbsolutePath.Trim('/'); if (string.IsNullOrEmpty(namespacePath)) { queueDescription = await host.CreateQueue(queueDescription).ConfigureAwait(false); queuePath = host.GetQueuePath(queueDescription); } else if (IsInNamespace(queueDescription, namespacePath)) { queueDescription.Path = queueDescription.Path.Replace(namespacePath, "").Trim('/'); queueDescription = await host.CreateQueue(queueDescription).ConfigureAwait(false); queuePath = host.GetQueuePath(queueDescription); } else { // queueDescription = await host.CreateQueue(queueDescription).ConfigureAwait(false); queueDescription = await host.RootNamespaceManager.CreateQueueSafeAsync(queueDescription).ConfigureAwait(false); queuePath = queueDescription.Path; } MessagingFactory messagingFactory = await host.MessagingFactory.ConfigureAwait(false); QueueClient queueClient = messagingFactory.CreateQueueClient(queuePath); var client = new QueueSendClient(queueClient); return new ServiceBusSendTransport(client, host.Supervisor); })); }
public Task<ISendTransport> GetSendTransport(Uri address) { IServiceBusHost host; if (!TryGetMatchingHost(address, out host)) throw new EndpointNotFoundException("The endpoint address specified an unknown host: " + address); return host.RetryPolicy.Retry<ISendTransport>(async () => { QueueDescription queueDescription = address.GetQueueDescription(); string queuePath; string namespacePath = host.NamespaceManager.Address.AbsolutePath.Trim('/'); if (string.IsNullOrEmpty(namespacePath)) { queueDescription = await host.CreateQueue(queueDescription).ConfigureAwait(false); queuePath = host.GetQueuePath(queueDescription); } else if (IsInNamespace(queueDescription, namespacePath)) { queueDescription.Path = queueDescription.Path.Replace(namespacePath, "").Trim('/'); queueDescription = await host.CreateQueue(queueDescription).ConfigureAwait(false); queuePath = host.GetQueuePath(queueDescription); } else { // queueDescription = await host.CreateQueue(queueDescription).ConfigureAwait(false); queueDescription = await host.RootNamespaceManager.CreateQueueSafeAsync(queueDescription).ConfigureAwait(false); queuePath = queueDescription.Path; } MessagingFactory messagingFactory = await host.MessagingFactory.ConfigureAwait(false); QueueClient queueClient = messagingFactory.CreateQueueClient(queuePath); var client = new QueueSendClient(queueClient); return new ServiceBusSendTransport(client, host.Supervisor); }); }