public void management_purges_queue()
		{
			address = TestDataFactory.GetAddress();
			
			new PurgeImpl(true, address)
				.Purge()
				.Wait();
		}
        public PurgeImpl(bool purgeExistingMessages,
            [NotNull] IAzureServiceBusEndpointAddress address)
        {
            if (address == null)
                throw new ArgumentNullException("address");

            _purgeExistingMessages = purgeExistingMessages;
            _address = address;
        }
        /// <summary>
        /// 	c'tor
        /// </summary>
        public OutboundAzureServiceBusTransport( IAzureServiceBusEndpointAddress address,  ConnectionHandler<AzureServiceBusConnection> connectionHandler, IOutboundSettings outboundSettings)
        {
            if (address == null)
                throw new ArgumentNullException("address");
            if (connectionHandler == null)
                throw new ArgumentNullException("connectionHandler");

            _connectionHandler = connectionHandler;
            _address = address;

            _logger.DebugFormat("created outbound transport for address '{0}'", address);
        }
        public void a_normal_address_and_its_topic_corresponding_address()
        {
            _queueAddress = AzureServiceBusEndpointAddress.Parse(
                TestDataFactory.ApplicationEndpoint);

            var formatter = new AzureServiceBusMessageNameFormatter();
            _topicName = formatter.GetMessageName(typeof (A)).ToString();

            _topicAddress = _queueAddress.ForTopic(_topicName);

            Assert.Throws<ArgumentNullException>(
                () => _queueAddress.ForTopic(null));
        }
        public InboundAzureServiceBusTransport(IAzureServiceBusEndpointAddress address,
            ConnectionHandler<AzureServiceBusConnection> connectionHandler,
            IMessageNameFormatter formatter = null,
            IInboundSettings inboundSettings = null)
        {
            if (address == null)
                throw new ArgumentNullException("address");
            if (connectionHandler == null)
                throw new ArgumentNullException("connectionHandler");

            _address = address;
            _connectionHandler = connectionHandler;
            _formatter = formatter ?? new AzureServiceBusMessageNameFormatter();
            _inboundSettings = inboundSettings;

            _logger.DebugFormat("created new inbound transport for '{0}'", address);
        }
        /// <summary>
        /// 	c'tor
        /// </summary>
        public AzureServiceBusOutboundTransport(
            [NotNull] IAzureServiceBusEndpointAddress address,
            [NotNull] ConnectionHandler<AzureServiceBusConnection> 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 AzureServiceBusConnection(
            [NotNull] IAzureServiceBusEndpointAddress 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);
        }
        /// <summary>
        ///     A connection is stored per connection string
        /// </summary>
        /// <param name="address"></param>
        /// <param name="tokenProvider"></param>
        /// <exception cref="ArgumentNullException"></exception>
        public AzureServiceBusConnectionImpl(IAzureServiceBusEndpointAddress address, TokenProvider tokenProvider)
        {
            if (address == null)
                throw new ArgumentNullException("address");

            _address = address;
            _tokenProvider = tokenProvider;

            _serviceUri = ServiceBusEnvironment.CreateServiceUri("sb", _address.Namespace, string.Empty);

            /*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("Connection '{0}' created at {1}", _address, _serviceUri);
        }
        public AzureServiceBusInboundTransport([NotNull] IAzureServiceBusEndpointAddress address,
            [NotNull] ConnectionHandler<AzureServiceBusConnection> 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 AzureServiceBusMessageNameFormatter();
            _receiverSettings = receiverSettings; // can be null all the way to usage in Receiver.

            _logger.DebugFormat("created new inbound transport for '{0}'", address);
        }
示例#10
0
        public PerConnectionReceiver(
            [NotNull] IAzureServiceBusEndpointAddress 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;
        }
 public Publisher(IAzureServiceBusEndpointAddress address)
 {
     _address       = address;
     _subscriptions = new HashSet <SubscriptionDescription>(new SubscriptionDescriptionEqualityComparer());
     _topics        = new HashSet <string>();
 }
 public void a_servicebusqueues_address_is_given()
 {
     _address = AzureServiceBusEndpointAddress.Parse(
         TestDataFactory.ApplicationEndpoint);
 }
 public Producer(IAzureServiceBusEndpointAddress address)
 {
     _address = address;
 }
        ConnectionHandler<AzureServiceBusConnection> GetConnection(
            Cache<string, ConnectionHandler<AzureServiceBusConnection>> cache,
            IAzureServiceBusEndpointAddress address)
        {
            var ns = address.Uri.Host;

            return cache.Get(ns, _ =>
                {
                    if (_log.IsDebugEnabled)
                        _log.DebugFormat("Creating RabbitMQ connection: {0}", address.Uri);

                    ConnectionSettingsBuilder builder = _connectionSettingsBuilders.Get(ns, __ =>
                        {
                            if (_log.IsDebugEnabled)
                                _log.DebugFormat("Using default configurator for connection: {0}", address.Uri);

                            var configurator = new NamespaceConnectionSettingsConfigurator(ns);

                            return configurator.Configure();
                        });

                    IConnectionSettings connectionSettings = builder.Build();

                    var connection = new AzureServiceBusConnectionImpl(address, connectionSettings.TokenProvider);

                    return new ConnectionHandlerImpl<AzureServiceBusConnection>(connection);
                });
        }
 /// <summary>
 ///     c'tor for consumer
 /// </summary>
 /// <param name="address">The address configured for the consumer</param>
 /// <param name="inboundSettings"></param>
 public Consumer(IAzureServiceBusEndpointAddress address, IInboundSettings inboundSettings)
 {
     _address = address;
 }
 public AzureManagementEndpointManagement(IAzureServiceBusEndpointAddress address)
 {
     _address = address;
 }
 public AzureManagementEndpointManagement(IAzureServiceBusEndpointAddress address)
 {
     _address = address;
 }
        public void a_servicebusqueues_address_is_given()
        {
            var extraHost = ".servicebus.windows.net";
            _extended = GetUri(extraHost);
            _normal = GetUri("");

            _addressExtended = AzureServiceBusEndpointAddress.Parse(_extended);
            _address = AzureServiceBusEndpointAddress.Parse(_normal);
        }
 public void a_servicebusqueues_address_is_given()
 {
     _address = AzureServiceBusEndpointAddress.Parse(
         TestDataFactory.ApplicationEndpoint);
 }