Exemple #1
0
        public bool RemoveMessage(string topic, string messageId)
        {
            TopicWiseBucketStatistics topicStats = _topicWiseMessageIds[topic] as TopicWiseBucketStatistics;

            if (topicStats != null)
            {
                int preUpdateSize = topicStats.InMemorySize;

                if (!topicStats.Remove(messageId))
                {
                    int postUpdateSize = topicStats.InMemorySize;

                    if (preUpdateSize != postUpdateSize)
                    {
                        _size -= preUpdateSize - postUpdateSize;
                    }
                }
                else
                {
                    _topicWiseMessageIds.Remove(topic);
                    _size -= preUpdateSize;
                    return(true);
                }
            }
            return(false);
        }
Exemple #2
0
        public OrderedDictionary GetTopicWiseMessagIds(bool includeEventMessages)
        {
            OrderedDictionary topicWiseMessages = new OrderedDictionary();

            foreach (string topic in _topicWiseMessageIds.Keys)
            {
                if (topic == null)
                {
                    continue;
                }

                if (TopicConstant.AllEventTopics.Contains(topic) && !includeEventMessages)
                {
                    continue;
                }

                TopicWiseBucketStatistics topicStats = _topicWiseMessageIds[topic] as TopicWiseBucketStatistics;

                if (topicStats != null)
                {
                    topicWiseMessages.Add(topic, topicStats.GetMessageIds());
                }
            }

            return(topicWiseMessages);
        }
Exemple #3
0
        public bool RemoveTopic(string topic)
        {
            TopicWiseBucketStatistics topicStats = _topicWiseMessageIds[topic] as TopicWiseBucketStatistics;

            if (topicStats != null)
            {
                _size -= topicStats.InMemorySize;
                _topicWiseMessageIds.Remove(topic);
                return(true);
            }
            return(false);
        }
Exemple #4
0
        public OrderedDictionary GetTopicWiseMessagIds()
        {
            OrderedDictionary topicWiseMessages = new OrderedDictionary();

            foreach (string topic in _topicWiseMessageIds.Keys)
            {
                TopicWiseBucketStatistics topicStats = _topicWiseMessageIds[topic] as TopicWiseBucketStatistics;

                if (topicStats != null)
                {
                    topicWiseMessages.Add(topic, topicStats.GetMessageIds());
                }
            }

            return(topicWiseMessages);
        }
Exemple #5
0
        public void AddMessage(string topic, string messageId)
        {
            TopicWiseBucketStatistics topicStats = _topicWiseMessageIds[topic] as TopicWiseBucketStatistics;

            if (topicStats == null)
            {
                topicStats = new TopicWiseBucketStatistics(topic);
                _topicWiseMessageIds.Add(topic, topicStats);
            }

            int preUpdateSize = topicStats.InMemorySize;

            topicStats.AddMessage(messageId);
            int postUpdateSize = topicStats.InMemorySize;

            if (preUpdateSize != postUpdateSize)
            {
                _size += postUpdateSize - preUpdateSize;
            }
        }