Exemplo n.º 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);
                        }
                    }
                }
            }
        }
Exemplo n.º 2
0
        private void DeleiverValidMessagesToClient(ReceivedMessages assignedResponse)
        {
            int count = 0;

            foreach (KeyValuePair <string, IList <MessageItem> > pair in assignedResponse.AssignedMessages)
            {
                Topic selectedTopic = null;
                foreach (var topic in _topicsDic.Values)
                {
                    selectedTopic = GetValidTopic(topic, pair.Key);
                    if (selectedTopic != null)
                    {
                        if (pair.Value != null && pair.Value.Count > 0)
                        {
                            count += pair.Value.Count;
                            selectedTopic.UpdateSyncData(pair.Value, pair.Key);
                        }
                    }
                }
            }

            if (_perfStatsCollector != null)
            {
                _perfStatsCollector.IncrementMessageDeliverPerSec(count);
            }
        }
Exemplo n.º 3
0
        private void Poll()
        {
            BitSet           flagMap          = new BitSet();
            ReceivedMessages assignedResponse = (ReceivedMessages)_cacheImpl.GetMessageData(flagMap);
            IDictionary <string, IList <MessageItem> > table = assignedResponse.AssignedMessages;

            if (assignedResponse != null)
            {
                //1: Send acknowlgement of messages to server side.
                SendMessageAcknowledgements(assignedResponse);

                //2:  raise event OnMesssageRecieved or OnMessageDeliveryFailure based on message type to subsriber or publishers.
                DeleiverValidMessagesToClient(assignedResponse);

                //3: If GetMessageData calls return dictionary with topic name and empty list. Then in this case verify topic existance on client side then either reregister topic or delete topic on client side
                // if user delete topic on server side from any publisher then subscriber must known about the delete topic call otherwise subscriber will always listening for upcoming messages
                // if subscriber client discoonected from server for short time period. While during this, any publisher recreated topic agian then after subscriber reconnect on the basic of poll command information registered topic again on server and clietn side.
                TopicValidation(assignedResponse);
            }

            _lastPoll = DateTime.Now;
        }
Exemplo n.º 4
0
        private void SendMessageAcknowledgements(ReceivedMessages assignedResponse)
        {
            var ackIdList = new Dictionary <string, IList <string> >();

            foreach (KeyValuePair <string, IList <MessageItem> > pair in assignedResponse.AssignedMessages)
            {
                IList <string> messageIds = new List <string>();
                foreach (MessageItem messageItem in pair.Value)
                {
                    messageIds.Add(messageItem.MessageId);
                }

                if (messageIds.Count > 0)
                {
                    ackIdList.Add(pair.Key, messageIds);
                }
            }

            if (ackIdList.Count > 0)
            {
                SendMesasgeAcknowledgment(ackIdList);
            }
        }