Beispiel #1
0
        private void TopicValidation(ReceivedMessages assignedResponse)
        {
            List <string> removeList = new List <string>();

            foreach (Topic topic in _topicsDic.Values)
            {
                TopicIdentity topicPair = new TopicIdentity(topic.Name, topic.SearchOptions);

                if (!assignedResponse.AssignedMessages.ContainsKey(topic.Name) && !assignedResponse.RegisteredPatterns.Contains(topic.Name))
                {
                    if (topic.HasFailureDeliveryNotification || topic.ActiveSubscriptions > 0)
                    {
                        if (topic.SearchOptions == TopicSearchOptions.ByName)
                        {
                            if (GetOrCreateTopic(topicPair, TopicOperationType.Get, true) != null)
                            {
                                topic.ReregisterSubscribers(topic.SearchOptions);
                            }
                        }

                        else
                        {
                            removeList.Add(topic.Name);
                        }
                    }
                }
            }
        }
Beispiel #2
0
        internal void DeleteTopic(string topicName)
        {
            if (_cacheImpl == null)
            {
                throw new OperationFailedException(ErrorCodes.CacheInit.CACHE_NOT_INIT, ErrorMessages.GetErrorMessage(ErrorCodes.CacheInit.CACHE_NOT_INIT));
            }

            if (IsDefaultTopicName(topicName))
            {
                return;
            }

            TopicIdentity topicPair = new TopicIdentity(topicName, TopicSearchOptions.ByName);
            Topic         topic;

            if (_topicsDic.TryRemove(topicPair, out topic))
            {
                if (topic.SearchOptions == TopicSearchOptions.ByName)
                {
                    topic.DisposeInternal(true);
                    StopPollingIfRequired(topic);
                }
            }
            _cacheImpl.RemoveTopic(topicName, true);
        }
Beispiel #3
0
        public ITopic CreateTopic(string topicName)
        {
            if (string.IsNullOrEmpty(topicName))
            {
                throw new ArgumentException("TopicName is null or empty string");
            }
            TopicIdentity topicPair = new TopicIdentity(topicName, TopicSearchOptions.ByName);

            return(PubSubManager.GetOrCreateTopic(topicPair, TopicOperationType.Create, false));
        }
Beispiel #4
0
 internal void TopicDisposeItself(Topic topic)
 {
     lock (this)
     {
         TopicIdentity topicPair = new TopicIdentity(topic.Name, topic.SearchOptions);
         Topic         existingtopic;
         if (_topicsDic.TryGetValue(topicPair, out existingtopic) && existingtopic == topic)
         {
             _topicsDic.TryRemove(topicPair, out existingtopic);
         }
     }
 }
Beispiel #5
0
        internal ITopic GetOrCreateTopic(TopicIdentity topicPair, TopicOperationType type, bool internalOperation)
        {
            if (string.IsNullOrEmpty(topicPair.TopicName))
            {
                throw new ArgumentException("TopicName is null or empty string");
            }


            if (!internalOperation && IsDefaultTopicName(topicPair.TopicName))
            {
                throw new OperationFailedException(ErrorCodes.PubSub.DEFAULT_TOPICS, ErrorMessages.GetErrorMessage(ErrorCodes.PubSub.DEFAULT_TOPICS));
            }

            if (_cacheImpl == null)
            {
                throw new OperationFailedException(ErrorCodes.CacheInit.CACHE_NOT_INIT, ErrorMessages.GetErrorMessage(ErrorCodes.CacheInit.CACHE_NOT_INIT));
            }

            Topic topic = null;

            if (_cacheImpl.GetOrCreate(topicPair.TopicName, type))
            {
                lock (this)
                {
                    if (_topicsDic.TryGetValue(topicPair, out topic))
                    {
                        if (topic.IsClosed)
                        {
                            _topicsDic.TryRemove(topicPair, out topic);
                            TopicSearchOptions searchOptions = topic.SearchOptions;
                            topic = new Topic(topicPair.TopicName, _cacheImpl, _perfStatsCollector, this);
                            topic.SearchOptions = searchOptions;
                        }

                        topic.IncrementRefCount();
                        return(topic);
                    }

                    topic = new Topic(topicPair.TopicName, _cacheImpl, _perfStatsCollector, this);

                    topic.IncrementRefCount();
                    _topicsDic.TryAdd(topicPair, topic);
                }
            }
            return(topic);
        }
Beispiel #6
0
        internal ITopic GetTopic(string topicName, bool flag)
        {
            TopicIdentity topicPair = new TopicIdentity(topicName, TopicSearchOptions.ByName);

            return(PubSubManager.GetOrCreateTopic(topicPair, TopicOperationType.Get, flag));
        }