/// <summary>
        ///     Builds the outbound error transport; where to send messages that fail.
        /// </summary>
        /// <param name="settings"> using these settings </param>
        /// <returns> The outbound transport instance, non null </returns>
        public virtual IOutboundTransport BuildError([NotNull] ITransportSettings settings)
        {
            if (settings == null)
            {
                throw new ArgumentNullException("settings");
            }
            EnsureProtocolIsCorrect(settings.Address.Uri);

            IAzureServiceBusEndpointAddress address = _addresses.Retrieve(settings.Address.Uri,
                                                                          () => AzureServiceBusEndpointAddress.Parse(settings.Address.Uri));

            _logger.DebugFormat("building error transport for address '{0}'", address);

            ConnectionHandler <AzureServiceBusConnection> client = GetConnection(address);

            return(new AzureServiceBusOutboundTransport(address, client, _senderSettings));
        }
        /// <summary>
        ///     Builds the outbound error transport; where to send messages that fail.
        /// </summary>
        /// <param name="settings"> using these settings </param>
        /// <returns> The outbound transport instance, non null </returns>
        public virtual IOutboundTransport BuildError([NotNull] ITransportSettings settings)
        {
            if (settings == null)
            {
                throw new ArgumentNullException("settings");
            }

            Uri uri = settings.Address.Uri;

            EnsureProtocolIsCorrect(uri);
            IAzureServiceBusEndpointAddress address = _addresses.Get(uri,
                                                                     key => AzureServiceBusEndpointAddress.Parse(uri, GetConnectionSettings(uri.Host)));

            _log.DebugFormat("building error transport for address '{0}'", address);

            ConnectionHandler <AzureServiceBusConnection> connectionHandler = GetConnection(_connections, address);

            return(new OutboundAzureServiceBusTransport(address, connectionHandler, _outboundSettings));
        }
        /// <summary>
        ///     Builds the inbound transport for the service bus endpoint,
        /// </summary>
        /// <param name="settings"> using these settings </param>
        /// <returns> A non-null instance of the inbound transport. </returns>
        public virtual IInboundTransport BuildInbound([NotNull] ITransportSettings settings)
        {
            if (settings == null)
            {
                throw new ArgumentNullException("settings");
            }

            EnsureProtocolIsCorrect(settings.Address.Uri);

            IAzureServiceBusEndpointAddress address = _addresses.Retrieve(settings.Address.Uri,
                                                                          () => AzureServiceBusEndpointAddress.Parse(settings.Address.Uri));

            _logger.DebugFormat("building inbound transport for address '{0}'", address);

            ConnectionHandler <AzureServiceBusConnection> client = GetConnection(address);

            return(new AzureServiceBusInboundTransport(address, client, new PurgeImpl(settings.PurgeExistingMessages, address),
                                                       MessageNameFormatter, _receiverSettings));
        }
 public IEndpointAddress GetAddress(Uri uri, bool transactional)
 {
     return(_addresses.Get(uri, _ => AzureServiceBusEndpointAddress.Parse(uri, GetConnectionSettings(uri.Host))));
 }