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;
        }
Ejemplo n.º 2
0
        public Task <ISendTransport> CreateSendTransport(Uri address)
        {
            var settings = _hostTopology.SendTopology.GetSendSettings(address);

            var endpointContextSupervisor = CreateQueueSendEndpointContextSupervisor(settings);

            var transport = new ServiceBusSendTransport(endpointContextSupervisor, address);

            _host.Add(transport);

            return(Task.FromResult <ISendTransport>(transport));
        }
Ejemplo n.º 3
0
        ISendTransport CreateSendTransport(Uri address, SendSettings settings)
        {
            TransportLogMessages.CreateSendTransport(address);

            var endpointContextSupervisor = CreateSendEndpointContextSupervisor(settings);

            var transportContext = new SendTransportContext(_hostConfiguration, address, endpointContextSupervisor);

            var transport = new ServiceBusSendTransport(transportContext);

            endpointContextSupervisor.Add(transport);

            return(transport);
        }
        public Task<ISendEndpoint> GetSendEndpoint(Uri address)
        {
            return _host.RetryPolicy.Retry<ISendEndpoint>(async () =>
            {
                var topicDescription = await _host.RootNamespaceManager.CreateTopicSafeAsync(address.GetTopicDescription()).ConfigureAwait(false);

                var messagingFactory = await _host.MessagingFactory.ConfigureAwait(false);

                var topicClient = messagingFactory.CreateTopicClient(topicDescription.Path);

                var client = new TopicSendClient(topicClient);

                var sendTransport = new ServiceBusSendTransport(client, _host.Supervisor);

                sendTransport.ConnectSendObserver(_sendObservable);

                return new SendEndpoint(sendTransport, _serializer, address, _sourceAddress, SendPipe.Empty);
            });
        }
        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, host.Supervisor);

            sendTransport.ConnectSendObserver(_sendObservable);

            return new SendEndpoint(sendTransport, _serializer, address, _sourceAddress, SendPipe.Empty);
        }
Ejemplo n.º 6
0
        public Task <ISendTransport> CreatePublishTransport <T>()
            where T : class
        {
            var publishTopology = _hostTopology.Publish <T>();

            if (!publishTopology.TryGetPublishAddress(_hostSettings.ServiceUri, 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 transport = new ServiceBusSendTransport(endpointContextSupervisor, publishAddress);

            _host.Add(transport);

            return(Task.FromResult <ISendTransport>(transport));
        }
        async Task <ISendTransport> GetSendTransport(Uri address)
        {
            var queueOrTopicName = address.AbsolutePath.Trim('/');

            var serviceBusTopic = new ServiceBusAttribute(queueOrTopicName, EntityType.Topic);

            IAsyncCollector <Message> collector = await _binder.BindAsync <IAsyncCollector <Message> >(serviceBusTopic, _cancellationToken).ConfigureAwait(false);

            LogContext.Debug?.Log("Creating Publish Transport: {Topic}", queueOrTopicName);

            var client = new CollectorMessageSendEndpointContext(queueOrTopicName, collector, _cancellationToken);

            var source = new CollectorSendEndpointContextSupervisor(client);

            var transportContext = new HostServiceBusSendTransportContext(address, source, LogContext.Current.CreateLogContext(LogCategoryName.Transport.Send));

            var transport = new ServiceBusSendTransport(transportContext);

            return(transport);
        }
        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);
        }
Ejemplo n.º 9
0
        async Task <ISendTransport> GetSendTransport(Uri address)
        {
            var queueOrTopicName = address.AbsolutePath.Trim('/');

            var serviceBusTopic = new ServiceBusAttribute(queueOrTopicName, EntityType.Topic);

            IAsyncCollector <Message> collector = await _binder.BindAsync <IAsyncCollector <Message> >(serviceBusTopic, _cancellationToken).ConfigureAwait(false);

            if (_log.IsDebugEnabled)
            {
                _log.DebugFormat("Creating Publish Transport: {0}", queueOrTopicName);
            }

            var client = new CollectorMessageSendEndpointContext(queueOrTopicName, _log, collector, _cancellationToken);

            var source = new CollectorSendEndpointContextSource(client);

            var transport = new ServiceBusSendTransport(source, address);

            return(transport);
        }