AzureServiceBusEndpointAddressImpl([NotNull] Data data,
                                           AddressType addressType)
        {
            if (data == null)
            {
                throw new ArgumentNullException("data");
            }

            _data = data;

            _tp = TokenProvider.CreateSharedSecretTokenProvider(_data.UsernameIssuer,
                                                                _data.PasswordSharedSecret);

            var sbUri = ServiceBusEnvironment.CreateServiceUri("sb", _data.Namespace, string.Empty);

            var mfs = new MessagingFactorySettings
            {
                TokenProvider = _tp,
                NetMessagingTransportSettings =
                {
                    // todo: configuration setting
                    BatchFlushInterval = 50.Milliseconds()
                },
                OperationTimeout = 3.Seconds()
            };

            _mff = () => MessagingFactory.Create(sbUri, mfs);

            _nm = new NamespaceManager(sbUri, _tp);

            string suffix = "";

            if (addressType == AddressType.Queue)
            {
                _queueDescription = new QueueDescriptionImpl(data.QueueOrTopicName);
            }
            else
            {
                _topicDescription = new TopicDescriptionImpl(data.QueueOrTopicName);
                suffix            = "?topic=true";
            }

            _rebuiltUri = new Uri(string.Format("azure-sb://{0}:{1}@{2}/{3}{4}",
                                                data.UsernameIssuer,
                                                data.PasswordSharedSecret,
                                                data.Namespace,
                                                data.QueueOrTopicName,
                                                suffix));

            _friendlyUri = new Uri(string.Format("azure-sb://{0}/{1}{2}",
                                                 data.Namespace,
                                                 data.QueueOrTopicName,
                                                 suffix));
        }
		AzureServiceBusEndpointAddressImpl([NotNull] Data data,
			AddressType addressType)
		{
			if (data == null)
				throw new ArgumentNullException("data");

			_data = data;

			_tp = TokenProvider.CreateSharedSecretTokenProvider(_data.UsernameIssuer,
			                                                    _data.PasswordSharedSecret);

			var sbUri = ServiceBusEnvironment.CreateServiceUri("sb", _data.Namespace, string.Empty);

			var mfs = new MessagingFactorySettings
				{
					TokenProvider = _tp,
					NetMessagingTransportSettings =
						{
							// todo: configuration setting
							BatchFlushInterval = 50.Milliseconds()
						},
					OperationTimeout = 3.Seconds()
				};
			_mff = () => MessagingFactory.Create(sbUri, mfs);

			_nm = new NamespaceManager(sbUri, _tp);

			string suffix = "";
			if (addressType == AddressType.Queue)
				_queueDescription = new QueueDescriptionImpl(data.QueueOrTopicName);
			else
			{
				_topicDescription = new TopicDescriptionImpl(data.QueueOrTopicName);
				suffix = "?topic=true";
			}

			_rebuiltUri = new Uri(string.Format("azure-sb://{0}:{1}@{2}/{3}{4}", 
				data.UsernameIssuer,
				data.PasswordSharedSecret,
				data.Namespace,
				data.QueueOrTopicName,
				suffix));

			_friendlyUri = new Uri(string.Format("azure-sb://{0}/{1}{2}",
				data.Namespace,
				data.QueueOrTopicName,
				suffix));
		}
Ejemplo n.º 3
0
        /// <summary>
        /// Asynchronously create a new message sender.
        /// </summary>
        public static Task <MessageSender> TryCreateMessageSender(
            [NotNull] this MessagingFactory mf,
            [NotNull] QueueDescription description,
            int prefetchCount)
        {
            if (mf == null)
            {
                throw new ArgumentNullException("mf");
            }
            if (description == null)
            {
                throw new ArgumentNullException("description");
            }

            return(Task.Factory.StartNew(() =>
            {
                var qc = mf.CreateQueueClient(description.Path);
                qc.PrefetchCount = prefetchCount;
                return new MessageSenderImpl(qc) as MessageSender;
            }));
        }