예제 #1
0
        /// <summary>
        /// Sends back the specified message to its source publisher or source topic.
        /// </summary>
        /// <param name="returnToTopic">true to return message to its source topic; otherwise, to its source publisher if possible.</param>
        public void Return(bool returnToTopic = false)
        {
            var returnMessage = this.Clone();

            returnMessage.IsReturned = true;

            if (returnToTopic || Utilities.IsNullOrWhiteSpace(returnMessage.LastPublisher))
            {
                if (!Utilities.IsNullOrWhiteSpace(returnMessage.LastTopic))
                {
                    Topic topic = ServiceBusManager.GetTopic(returnMessage.LastTopic);

                    if (topic != null)
                    {
                        topic.Accept(returnMessage);
                    }
                }
            }
            else
            {
                PublisherClient publisher = ServiceBusManager.GetPublisher(returnMessage.LastPublisher);

                if (publisher != null)
                {
                    publisher.Send(returnMessage);
                }
            }
        }
예제 #2
0
        /// <summary>
        /// Removes the topic from current PublisherClient publish list.
        /// </summary>
        /// <param name="topicName">Name of the topic.</param>
        /// <returns>Current PublisherClient.</returns>
        public PublisherClient RemoveTopic(string topicName = null)
        {
            this.CheckDisposed();

            ServiceBusManager.RemoveLinkPublisherTopic(this.Name, topicName);

            return(this);
        }
예제 #3
0
        /// <summary>
        /// Adds the topic to current PublisherClient publish list.
        /// </summary>
        /// <param name="topicName">Name of the topic.</param>
        /// <returns>Current PublisherClient.</returns>
        public PublisherClient AddTopic(string topicName)
        {
            this.CheckDisposed();

            ServiceBusManager.LinkPublisherTopic(this.Name, topicName);

            return(this);
        }
예제 #4
0
        /// <summary>
        /// Removes the subscription.
        /// </summary>
        /// <param name="subscriptionName">Name of the subscription.</param>
        /// <returns>Current Topic.</returns>
        public Topic RemoveSubscription(string subscriptionName)
        {
            this.CheckDisposed();

            ServiceBusManager.RemoveLinkSubscriptionTopic(subscriptionName, this.Name);

            return(this);
        }
예제 #5
0
        /// <summary>
        /// Removes the publisher.
        /// </summary>
        /// <param name="publisherName">Name of the publisher.</param>
        /// <returns>Current Topic.</returns>
        public Topic RemovePublisher(string publisherName)
        {
            this.CheckDisposed();

            ServiceBusManager.RemoveLinkPublisherTopic(publisherName, this.Name);

            return(this);
        }
예제 #6
0
        /// <summary>
        /// Removes the topic.
        /// </summary>
        /// <param name="topicName">Name of the topic.</param>
        /// <returns>Current SubscriptionClient.</returns>
        public SubscriptionClient RemoveTopic(string topicName)
        {
            this.CheckDisposed();

            ServiceBusManager.RemoveLinkSubscriptionTopic(this.Name, topicName);

            return(this);
        }
예제 #7
0
        /// <summary>
        /// Removes all topics from current PublisherClient publish list.
        /// </summary>
        /// <returns>Current PublisherClient.</returns>
        public PublisherClient RemoveAllTopics()
        {
            this.CheckDisposed();

            Dictionary <string, Topic> .KeyCollection topics = null;

            lock (Utilities.GetSyncRoot(this._topics))
            {
                topics = this._topics.Keys;
            }

            if (topics != null)
            {
                foreach (var topic in topics)
                {
                    ServiceBusManager.RemoveLinkPublisherTopic(this.Name, topic);
                }
            }

            return(this);
        }
예제 #8
0
        /// <summary>
        /// Removes all subscriptions.
        /// </summary>
        /// <returns>Current Topic.</returns>
        public Topic RemoveAllSubscriptions()
        {
            this.CheckDisposed();

            Dictionary <string, SubscriptionClient> .KeyCollection subscriptions = null;

            lock (Utilities.GetSyncRoot(this._subscriptions))
            {
                subscriptions = this._subscriptions.Keys;
            }

            if (subscriptions != null)
            {
                foreach (var subscription in subscriptions)
                {
                    ServiceBusManager.RemoveLinkSubscriptionTopic(subscription, this.Name);
                }
            }

            return(this);
        }
예제 #9
0
        /// <summary>
        /// Removes all publishers.
        /// </summary>
        /// <returns>Current Topic.</returns>
        public Topic RemoveAllPublishers()
        {
            this.CheckDisposed();

            Dictionary <string, PublisherClient> .KeyCollection publishers = null;

            lock (Utilities.GetSyncRoot(this._publishers))
            {
                publishers = this._publishers.Keys;
            }

            if (publishers != null)
            {
                foreach (var publisher in publishers)
                {
                    ServiceBusManager.RemoveLinkPublisherTopic(publisher, this.Name);
                }
            }

            return(this);
        }