public void SignalBoundSubscription(Guid key, TopicDescription topic, Type messageType)
 {
     lock (_subscribed)
         if (!_subscribed.Has(key))
         {
             _subscribed.Add(key, new Tuple <TopicDescription, Type>(topic, messageType));
         }
 }
Exemple #2
0
 /// <summary>
 /// Asynchronously create a new message sender.
 /// </summary>
 public static Task <MessageSender> TryCreateMessageSender(
     [NotNull] this MessagingFactory mf,
     [NotNull] TopicDescription description)
 {
     return(Task.Factory.StartNew(() =>
     {
         var s = mf.CreateTopicClient(description.Path);
         return new MessageSenderImpl(s) as MessageSender;
     }));
 }
        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));
		}
		public void SignalBoundSubscription(Guid key, TopicDescription topic, Type messageType)
		{
			lock (_subscribed)
				if (!_subscribed.Has(key))
					_subscribed.Add(key, new Tuple<TopicDescription, Type>(topic, messageType));
		}
		public void SignalUnboundSubscription(Guid key, TopicDescription value)
		{
			lock (_subscribed)
				if (_subscribed.Has(key))
					_subscribed.Remove(key);
		}
		public void SignalBoundSubscription(Guid key, TopicDescription value)
		{
			lock (_subscribed)
				if (!_subscribed.Has(key))
					_subscribed.Add(key, value);
		}