public InboundTransportImpl([NotNull] AzureServiceBusEndpointAddress address,
                                    [NotNull] ConnectionHandler <ConnectionImpl> connectionHandler,
                                    [NotNull] AzureManagement management,
                                    [CanBeNull] IMessageNameFormatter formatter   = null,
                                    [CanBeNull] ReceiverSettings receiverSettings = null)
        {
            if (address == null)
            {
                throw new ArgumentNullException("address");
            }
            if (connectionHandler == null)
            {
                throw new ArgumentNullException("connectionHandler");
            }
            if (management == null)
            {
                throw new ArgumentNullException("management");
            }

            _address           = address;
            _connectionHandler = connectionHandler;
            _management        = management;
            _formatter         = formatter ?? new AzureMessageNameFormatter();
            _receiverSettings  = receiverSettings;            // can be null all the way to usage in Receiver.

            _logger.DebugFormat("created new inbound transport for '{0}'", address);
        }
		/// <summary>
		/// 	c'tor
		/// </summary>
		public OutboundTransportImpl(
			[NotNull] AzureServiceBusEndpointAddress address,
			[NotNull] ConnectionHandler<ConnectionImpl> connectionHandler, 
			[NotNull] SenderSettings settings)
		{
			if (address == null) throw new ArgumentNullException("address");
			if (connectionHandler == null) throw new ArgumentNullException("connectionHandler");
			if (settings == null) throw new ArgumentNullException("settings");

			_connectionHandler = connectionHandler;
			_settings = settings;
			_address = address;

			_logger.DebugFormat("created outbound transport for address '{0}'", address);
		}
Exemple #3
0
        ConnectionHandler <ConnectionImpl> GetConnection([NotNull] AzureServiceBusEndpointAddress address)
        {
            if (address == null)
            {
                throw new ArgumentNullException("address");
            }
            _logger.DebugFormat("get connection( address:'{0}' )", address);

            return(_connCache.Retrieve(address.Uri, () =>
            {
                var connection = new ConnectionImpl(address);
                var connectionHandler = new ConnectionHandlerImpl <ConnectionImpl>(connection);

                return connectionHandler;
            }));
        }
		public ConnectionImpl(
			[NotNull] AzureServiceBusEndpointAddress endpointAddress,
			int prefetchCount = 1000) // todo: configuration setting
		{
			if (endpointAddress == null) throw new ArgumentNullException("endpointAddress");

			_endpointAddress = endpointAddress;
			_prefetchCount = prefetchCount;

			/*When using the default lock expiration of 60 seconds, a good value for SubscriptionClient.PrefetchCount
			 * is 20 times the maximum processing rates of all receivers of the factory. For example,
			 * a factory creates 3 receivers. Each receiver can process up to 10 messages per second.
			 * The prefetch count should not exceed 20*3*10 = 600.By default, QueueClient.PrefetchCount
			 * is set to 0, which means that no additional messages are fetched from the service. */

			_log.DebugFormat("created connection impl for address ('{0}')", endpointAddress);
		}
Exemple #5
0
        public static bool TryParse([NotNull] Uri inputUri, out AzureServiceBusEndpointAddress address,
                                    out IEnumerable <ValidationResult> validationResults)
        {
            if (inputUri == null)
            {
                throw new ArgumentNullException("inputUri");
            }
            Data data;

            if (TryParseInternal(inputUri, out data, out validationResults))
            {
                address = new AzureServiceBusEndpointAddress(data, data.AddressType);
                return(true);
            }
            address = null;
            return(false);
        }
        /// <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));
        }
		public InboundTransportImpl([NotNull] AzureServiceBusEndpointAddress address,
			[NotNull] ConnectionHandler<ConnectionImpl> connectionHandler,
			[NotNull] AzureManagement management, 
			[CanBeNull] IMessageNameFormatter formatter = null,
			[CanBeNull] ReceiverSettings receiverSettings = null)
		{
			if (address == null) throw new ArgumentNullException("address");
			if (connectionHandler == null) throw new ArgumentNullException("connectionHandler");
			if (management == null) throw new ArgumentNullException("management");

			_address = address;
			_connectionHandler = connectionHandler;
			_management = management;
			_formatter = formatter ?? new AzureMessageNameFormatter();
			_receiverSettings = receiverSettings; // can be null all the way to usage in Receiver.

			_logger.DebugFormat("created new inbound transport for '{0}'", address);
		}
        /// <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));
        }
Exemple #10
0
        public ConnectionImpl(
            [NotNull] AzureServiceBusEndpointAddress endpointAddress,
            int prefetchCount = 1000)             // todo: configuration setting
        {
            if (endpointAddress == null)
            {
                throw new ArgumentNullException("endpointAddress");
            }

            _endpointAddress = endpointAddress;
            _prefetchCount   = prefetchCount;

            /*When using the default lock expiration of 60 seconds, a good value for SubscriptionClient.PrefetchCount
             * is 20 times the maximum processing rates of all receivers of the factory. For example,
             * a factory creates 3 receivers. Each receiver can process up to 10 messages per second.
             * The prefetch count should not exceed 20*3*10 = 600.By default, QueueClient.PrefetchCount
             * is set to 0, which means that no additional messages are fetched from the service. */

            _log.DebugFormat("created connection impl for address ('{0}')", endpointAddress);
        }
        public PerConnectionReceiver(
            [NotNull] AzureServiceBusEndpointAddress address,
            [NotNull] ReceiverSettings settings,
            [NotNull] Action <Receiver.Receiver> onBound,
            [NotNull] Action <Receiver.Receiver> onUnbound)
        {
            if (address == null)
            {
                throw new ArgumentNullException("address");
            }
            if (onBound == null)
            {
                throw new ArgumentNullException("onBound");
            }
            if (onUnbound == null)
            {
                throw new ArgumentNullException("onUnbound");
            }

            _address   = address;
            _settings  = settings;
            _onBound   = onBound;
            _onUnbound = onUnbound;
        }
        /// <summary>
        ///     c'tor
        /// </summary>
        public OutboundTransportImpl(
            [NotNull] AzureServiceBusEndpointAddress address,
            [NotNull] ConnectionHandler <ConnectionImpl> connectionHandler,
            [NotNull] SenderSettings settings)
        {
            if (address == null)
            {
                throw new ArgumentNullException("address");
            }
            if (connectionHandler == null)
            {
                throw new ArgumentNullException("connectionHandler");
            }
            if (settings == null)
            {
                throw new ArgumentNullException("settings");
            }

            _connectionHandler = connectionHandler;
            _settings          = settings;
            _address           = address;

            _logger.DebugFormat("created outbound transport for address '{0}'", address);
        }
 public static bool TryParse([NotNull] Uri inputUri, out AzureServiceBusEndpointAddress address,
     out IEnumerable<ValidationResult> validationResults)
 {
     if (inputUri == null)
         throw new ArgumentNullException("inputUri");
     Data data;
     if (TryParseInternal(inputUri, out data, out validationResults))
     {
         address = new AzureServiceBusEndpointAddress(data, data.AddressType);
         return true;
     }
     address = null;
     return false;
 }
 public IEndpointAddress GetAddress(Uri uri, bool transactional)
 {
     return(_addresses.Get(uri, _ => AzureServiceBusEndpointAddress.Parse(uri, GetConnectionSettings(uri.Host))));
 }