Exemplo n.º 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));
            }
        }
Exemplo n.º 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));
            }
        }
Exemplo n.º 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));
            }
        }
Exemplo n.º 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);
 }
Exemplo n.º 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);
        }
Exemplo n.º 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));
            }
        }
Exemplo n.º 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);
        }
Exemplo n.º 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;
 }
Exemplo n.º 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;
 }
Exemplo n.º 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;
 }
Exemplo n.º 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;
        }
Exemplo n.º 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;
        }
Exemplo n.º 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;
        }
Exemplo n.º 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);
 }
Exemplo n.º 15
0
 public void GetOrAddChannel(ClientChannel clientChannel)
 {
     var currentChannel = _consumerChannelDict.GetOrAdd(clientChannel.Channel.RemotingAddress, clientChannel);
     currentChannel.LastUpdateTime = DateTime.Now;
 }
Exemplo n.º 16
0
 public void UpdateChannelSubscriptionTopics(ClientChannel clientChannel, IEnumerable <string> subscriptionTopics)
 {
     _clientSubscriptionTopicDict.AddOrUpdate(clientChannel.ClientId, subscriptionTopics, (key, old) => subscriptionTopics);
 }
Exemplo n.º 17
0
 public void UpdateChannelSubscriptionTopics(ClientChannel clientChannel, IEnumerable<string> subscriptionTopics)
 {
     _clientSubscriptionTopicDict.AddOrUpdate(clientChannel.ClientId, subscriptionTopics, (key, old) => subscriptionTopics);
 }