示例#1
0
        public void UpdateConsumerSubscriptionTopics(ClientChannel clientChannel, IEnumerable <string> subscriptionTopics)
        {
            var subscriptionTopicChanged = false;
            IEnumerable <string> oldSubscriptionTopics = new List <string>();
            IEnumerable <string> newSubscriptionTopics = new List <string>();

            _consumerSubscriptionTopicDict.AddOrUpdate(clientChannel.ClientId,
                                                       key =>
            {
                subscriptionTopicChanged = true;
                newSubscriptionTopics    = subscriptionTopics;
                return(subscriptionTopics);
            },
                                                       (key, old) =>
            {
                if (IsStringCollectionChanged(old.ToList(), subscriptionTopics.ToList()))
                {
                    subscriptionTopicChanged = true;
                    oldSubscriptionTopics    = old;
                    newSubscriptionTopics    = subscriptionTopics;
                }
                return(subscriptionTopics);
            });

            if (subscriptionTopicChanged)
            {
                _logger.InfoFormat("Consumer subscription topics changed. groupName:{0}, consumerId:{1}, old:{2}, new:{3}", _groupName, clientChannel.ClientId, string.Join("|", oldSubscriptionTopics), string.Join("|", newSubscriptionTopics));
            }
        }
示例#2
0
        public void UpdateConsumerConsumingQueues(ClientChannel clientChannel, IEnumerable <string> consumingQueues)
        {
            var consumingQueueChanged = false;
            IEnumerable <string> oldConsumingQueues = new List <string>();
            IEnumerable <string> newConsumingQueues = new List <string>();

            _consumerConsumingQueueDict.AddOrUpdate(clientChannel.ClientId,
                                                    key =>
            {
                newConsumingQueues = consumingQueues;
                if (consumingQueues.Count() > 0)
                {
                    consumingQueueChanged = true;
                }
                return(consumingQueues);
            },
                                                    (key, old) =>
            {
                if (IsStringCollectionChanged(old.ToList(), consumingQueues.ToList()))
                {
                    consumingQueueChanged = true;
                    oldConsumingQueues    = old;
                    newConsumingQueues    = consumingQueues;
                }
                return(consumingQueues);
            });

            if (consumingQueueChanged)
            {
                _logger.InfoFormat("Consumer consuming queues changed. groupName:{0}, consumerId:{1}, old:{2}, new:{3}", _groupName, clientChannel.ClientId, string.Join("|", oldConsumingQueues), string.Join("|", newConsumingQueues));
            }
        }
示例#3
0
        public void UpdateConsumerConsumingQueues(ClientChannel clientChannel, IEnumerable<string> consumingQueues)
        {
            var consumingQueueChanged = false;
            IEnumerable<string> oldConsumingQueues = new List<string>();
            IEnumerable<string> newConsumingQueues = new List<string>();

            _consumerConsumingQueueDict.AddOrUpdate(clientChannel.ClientId,
            key =>
            {
                newConsumingQueues = consumingQueues;
                if (consumingQueues.Count() > 0)
                {
                    consumingQueueChanged = true;
                }
                return consumingQueues;
            },
            (key, old) =>
            {
                if (IsStringCollectionChanged(old.ToList(), consumingQueues.ToList()))
                {
                    consumingQueueChanged = true;
                    oldConsumingQueues = old;
                    newConsumingQueues = consumingQueues;
                }
                return consumingQueues;
            });

            if (consumingQueueChanged)
            {
                _logger.InfoFormat("Consumer consuming queues changed. groupName:{0}, consumerId:{1}, old:{2}, new:{3}", _groupName, clientChannel.ClientId, string.Join("|", oldConsumingQueues), string.Join("|", newConsumingQueues));
            }
        }
示例#4
0
 public void RegisterConsumer(string groupName, ClientChannel clientChannel, IEnumerable<string> subscriptionTopics, IEnumerable<string> consumingQueues)
 {
     var consumerGroup = _consumerGroupDict.GetOrAdd(groupName, new ConsumerGroup(groupName, this));
     consumerGroup.Register(clientChannel);
     consumerGroup.UpdateConsumerSubscriptionTopics(clientChannel, subscriptionTopics);
     consumerGroup.UpdateConsumerConsumingQueues(clientChannel, consumingQueues);
 }
示例#5
0
        public void RegisterConsumer(string groupName, ClientChannel clientChannel, IEnumerable <string> subscriptionTopics)
        {
            var consumerGroup = _consumerGroupDict.GetOrAdd(groupName, new ConsumerGroup(groupName));

            consumerGroup.GetOrAddChannel(clientChannel);
            consumerGroup.UpdateChannelSubscriptionTopics(clientChannel, subscriptionTopics);
        }
示例#6
0
        public void UpdateConsumerSubscriptionTopics(ClientChannel clientChannel, IEnumerable<string> subscriptionTopics)
        {
            var subscriptionTopicChanged = false;
            IEnumerable<string> oldSubscriptionTopics = new List<string>();
            IEnumerable<string> newSubscriptionTopics = new List<string>();

            _consumerSubscriptionTopicDict.AddOrUpdate(clientChannel.ClientId,
            key =>
            {
                subscriptionTopicChanged = true;
                newSubscriptionTopics = subscriptionTopics;
                return subscriptionTopics;
            },
            (key, old) =>
            {
                if (IsStringCollectionChanged(old.ToList(), subscriptionTopics.ToList()))
                {
                    subscriptionTopicChanged = true;
                    oldSubscriptionTopics = old;
                    newSubscriptionTopics = subscriptionTopics;
                }
                return subscriptionTopics;
            });

            if (subscriptionTopicChanged)
            {
                _logger.InfoFormat("Consumer subscription topics changed. groupName:{0}, consumerId:{1}, old:{2}, new:{3}", _groupName, clientChannel.ClientId, string.Join("|", oldSubscriptionTopics), string.Join("|", newSubscriptionTopics));
            }
        }
示例#7
0
        public void RegisterConsumer(string groupName, ClientChannel clientChannel, IEnumerable <string> subscriptionTopics, IEnumerable <string> consumingQueues)
        {
            var consumerGroup = _consumerGroupDict.GetOrAdd(groupName, new ConsumerGroup(groupName, this));

            consumerGroup.Register(clientChannel);
            consumerGroup.UpdateConsumerSubscriptionTopics(clientChannel, subscriptionTopics);
            consumerGroup.UpdateConsumerConsumingQueues(clientChannel, consumingQueues);
        }
示例#8
0
 public void Register(ClientChannel clientChannel)
 {
     var consumer = _consumerDict.AddOrUpdate(clientChannel.ClientId, key =>
     {
         _logger.InfoFormat("Consumer added into group. groupName:{0}, consumerId:{1}, remotingAddress:{2}", _groupName, clientChannel.ClientId, clientChannel.Channel.RemotingAddress);
         return clientChannel;
     }, (key, old) => clientChannel);
     consumer.LastUpdateTime = DateTime.Now;
 }
示例#9
0
 public void GetOrAddChannel(ClientChannel clientChannel)
 {
     var currentChannel = _consumerChannelDict.GetOrAdd(clientChannel.Channel.RemotingAddress, key =>
     {
         _logger.DebugFormat("Added consumer client into consumer group. consumerGroup:{0}, consumerId:{1}, channel:{2}", _groupName, clientChannel.ClientId, clientChannel.Channel);
         return clientChannel;
     });
     currentChannel.LastUpdateTime = DateTime.Now;
 }
示例#10
0
 public void Register(ClientChannel clientChannel)
 {
     var consumer = _consumerDict.AddOrUpdate(clientChannel.ClientId, key =>
     {
         _logger.InfoFormat("Consumer registered. consumerGroup:{0}, consumerId:{1}, remotingEndPoint:{2}", _groupName, clientChannel.ClientId, clientChannel.Channel.RemotingEndPoint);
         return clientChannel;
     }, (key, old) => clientChannel);
     consumer.LastUpdateTime = DateTime.Now;
 }
示例#11
0
        public void GetOrAddChannel(ClientChannel clientChannel)
        {
            var currentChannel = _consumerChannelDict.GetOrAdd(clientChannel.Channel.RemotingAddress, key =>
            {
                _logger.DebugFormat("Added consumer client into consumer group. consumerGroup:{0}, consumerId:{1}, channel:{2}", _groupName, clientChannel.ClientId, clientChannel.Channel);
                return(clientChannel);
            });

            currentChannel.LastUpdateTime = DateTime.Now;
        }
示例#12
0
        public void Register(ClientChannel clientChannel)
        {
            var consumer = _consumerDict.AddOrUpdate(clientChannel.ClientId, key =>
            {
                _logger.InfoFormat("Consumer added into group. groupName:{0}, consumerId:{1}, remotingAddress:{2}", _groupName, clientChannel.ClientId, clientChannel.Channel.RemoteEndPoint.ToString());
                return(clientChannel);
            }, (key, old) => clientChannel);

            consumer.LastUpdateTime = DateTime.Now;
        }
示例#13
0
        public void Register(ClientChannel clientChannel)
        {
            var consumer = _consumerDict.AddOrUpdate(clientChannel.ClientId, key =>
            {
                _logger.InfoFormat("Consumer registered. consumerGroup:{0}, consumerId:{1}, remotingEndPoint:{2}", _groupName, clientChannel.ClientId, clientChannel.Channel.RemotingEndPoint);
                return(clientChannel);
            }, (key, old) => clientChannel);

            consumer.LastUpdateTime = DateTime.Now;
        }
示例#14
0
 public void RegisterConsumer(string groupName, ClientChannel clientChannel, IEnumerable<string> subscriptionTopics)
 {
     var consumerGroup = _consumerGroupDict.GetOrAdd(groupName, new ConsumerGroup(groupName));
     consumerGroup.GetOrAddChannel(clientChannel);
     consumerGroup.UpdateChannelSubscriptionTopics(clientChannel, subscriptionTopics);
 }
示例#15
0
 public void GetOrAddChannel(ClientChannel clientChannel)
 {
     var currentChannel = _consumerChannelDict.GetOrAdd(clientChannel.Channel.RemotingAddress, clientChannel);
     currentChannel.LastUpdateTime = DateTime.Now;
 }
示例#16
0
 public void UpdateChannelSubscriptionTopics(ClientChannel clientChannel, IEnumerable <string> subscriptionTopics)
 {
     _clientSubscriptionTopicDict.AddOrUpdate(clientChannel.ClientId, subscriptionTopics, (key, old) => subscriptionTopics);
 }
示例#17
0
 public void UpdateChannelSubscriptionTopics(ClientChannel clientChannel, IEnumerable<string> subscriptionTopics)
 {
     _clientSubscriptionTopicDict.AddOrUpdate(clientChannel.ClientId, subscriptionTopics, (key, old) => subscriptionTopics);
 }