Exemplo n.º 1
0
        public async Task <ISendTransport> CreateSendTransport(ServiceBusEndpointAddress address)
        {
            Task <CachedSendTransport> Create(Uri transportAddress)
            {
                var settings = _hostTopology.SendTopology.GetSendSettings(address);

                var endpointContextSupervisor = CreateQueueSendEndpointContextSupervisor(settings);

                var transportContext = new HostServiceBusSendTransportContext(address, endpointContextSupervisor, SendLogContext);

                var transport = new ServiceBusSendTransport(transportContext);

                Add(transport);

                return(Task.FromResult(new CachedSendTransport(transportAddress, transport)));
            }

            return(await _index.Get(address, Create).ConfigureAwait(false));
        }
Exemplo n.º 2
0
        public Task <ISendTransport> CreatePublishTransport <T>()
            where T : class
        {
            var publishTopology = _hostTopology.Publish <T>();

            if (!publishTopology.TryGetPublishAddress(_hostConfiguration.HostAddress, out Uri publishAddress))
            {
                throw new ArgumentException($"The type did not return a valid publish address: {TypeMetadataCache<T>.ShortName}");
            }

            var settings = publishTopology.GetSendSettings();

            var endpointContextSupervisor = CreateTopicSendEndpointContextSupervisor(settings);

            var transportContext = new HostServiceBusSendTransportContext(publishAddress, endpointContextSupervisor, SendLogContext);

            var transport = new ServiceBusSendTransport(transportContext);

            Add(transport);

            return(Task.FromResult <ISendTransport>(transport));
        }
        public async Task <ISendEndpoint> GetSendEndpoint(Uri address)
        {
            IServiceBusHost host;

            if (!TryGetMatchingHost(address, out host))
            {
                throw new EndpointNotFoundException("The endpoint address specified an unknown host: " + address);
            }

            TopicDescription topicDescription =
                await(await host.RootNamespaceManager.ConfigureAwait(false)).CreateTopicSafeAsync(address.GetTopicDescription()).ConfigureAwait(false);

            MessagingFactory messagingFactory = await host.MessagingFactory.ConfigureAwait(false);

            MessageSender messageSender = await messagingFactory.CreateMessageSenderAsync(topicDescription.Path).ConfigureAwait(false);

            var sendTransport = new ServiceBusSendTransport(messageSender);

            sendTransport.ConnectSendObserver(_sendObservable);

            return(new SendEndpoint(sendTransport, _serializer, address, _sourceAddress));
        }
Exemplo n.º 4
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);
        }
        public async Task <ISendEndpoint> GetSendEndpoint(Uri address)
        {
            IServiceBusHost host =
                _hosts.FirstOrDefault(x => x.Settings.ServiceUri.Host.Equals(address.Host, StringComparison.OrdinalIgnoreCase));

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

            TopicDescription topicDescription =
                await(await host.RootNamespaceManager.ConfigureAwait(false)).CreateTopicSafeAsync(address.GetTopicDescription()).ConfigureAwait(false);

            MessagingFactory messagingFactory = await host.MessagingFactory.ConfigureAwait(false);

            MessageSender messageSender = await messagingFactory.CreateMessageSenderAsync(topicDescription.Path).ConfigureAwait(false);

            var sendTransport = new ServiceBusSendTransport(messageSender);

            sendTransport.ConnectSendObserver(_sendObservable);

            return(new SendEndpoint(sendTransport, _serializer, address, _sourceAddress));
        }