public Consumer(string groupName, ConsumerSetting setting) { if (groupName == null) { throw new ArgumentNullException("groupName"); } GroupName = groupName; Setting = setting ?? new ConsumerSetting(); _lockObject = new object(); _subscriptionTopics = new Dictionary<string, HashSet<string>>(); _topicQueuesDict = new ConcurrentDictionary<string, IList<MessageQueue>>(); _pullRequestDict = new ConcurrentDictionary<string, PullRequest>(); _remotingClient = new SocketRemotingClient(Setting.BrokerAddress, Setting.SocketSetting, Setting.LocalAddress); _adminRemotingClient = new SocketRemotingClient(Setting.BrokerAdminAddress, Setting.SocketSetting, Setting.LocalAdminAddress); _binarySerializer = ObjectContainer.Resolve<IBinarySerializer>(); _scheduleService = ObjectContainer.Resolve<IScheduleService>(); _allocateMessageQueueStragegy = ObjectContainer.Resolve<IAllocateMessageQueueStrategy>(); _logger = ObjectContainer.Resolve<ILoggerFactory>().Create(GetType().FullName); _remotingClient.RegisterConnectionEventListener(new ConnectionEventListener(this)); if (Setting.MessageHandleMode == MessageHandleMode.Sequential) { _consumingMessageQueue = new BlockingCollection<ConsumingMessage>(); _consumeMessageWorker = new Worker("ConsumeMessage", () => HandleMessage(_consumingMessageQueue.Take())); } _messageRetryQueue = new BlockingCollection<ConsumingMessage>(); }
public Consumer(string groupName, ConsumerSetting setting) { if (groupName == null) { throw new ArgumentNullException("groupName"); } GroupName = groupName; Setting = setting ?? new ConsumerSetting(); _lockObject = new object(); _subscriptionTopics = new Dictionary<string, HashSet<string>>(); _topicQueuesDict = new ConcurrentDictionary<string, IList<MessageQueue>>(); _pullRequestQueue = new BlockingCollection<PullRequest>(new ConcurrentQueue<PullRequest>()); _pullRequestDict = new ConcurrentDictionary<string, PullRequest>(); _messageRetryQueue = new BlockingCollection<ConsumingMessage>(new ConcurrentQueue<ConsumingMessage>()); _taskFactory = new TaskFactory(new LimitedConcurrencyLevelTaskScheduler(Setting.ConsumeThreadMaxCount)); _remotingClient = new SocketRemotingClient(Setting.BrokerAddress, Setting.SocketSetting, Setting.LocalAddress); _adminRemotingClient = new SocketRemotingClient(Setting.BrokerAdminAddress, Setting.SocketSetting, Setting.LocalAdminAddress); _binarySerializer = ObjectContainer.Resolve<IBinarySerializer>(); _scheduleService = ObjectContainer.Resolve<IScheduleService>(); _allocateMessageQueueStragegy = ObjectContainer.Resolve<IAllocateMessageQueueStrategy>(); _executePullRequestWorker = new Worker("ExecutePullRequest", ExecutePullRequest); _logger = ObjectContainer.Resolve<ILoggerFactory>().Create(GetType().FullName); _remotingClient.RegisterConnectionEventListener(new ConnectionEventListener(this)); }
public Consumer(string id, string groupName, ConsumerSetting setting) { if (id == null) { throw new ArgumentNullException("id"); } if (groupName == null) { throw new ArgumentNullException("groupName"); } Id = id; GroupName = groupName; Setting = setting ?? new ConsumerSetting(); _lockObject = new object(); _subscriptionTopics = new List <string>(); _topicQueuesDict = new ConcurrentDictionary <string, IList <MessageQueue> >(); _pullRequestQueue = new BlockingCollection <PullRequest>(new ConcurrentQueue <PullRequest>()); _pullRequestDict = new ConcurrentDictionary <string, PullRequest>(); _consumingMessageQueue = new BlockingCollection <ConsumingMessage>(new ConcurrentQueue <ConsumingMessage>()); _messageRetryQueue = new BlockingCollection <ConsumingMessage>(new ConcurrentQueue <ConsumingMessage>()); _handlingMessageDict = new ConcurrentDictionary <long, ConsumingMessage>(); _taskIds = new List <int>(); _taskFactory = new TaskFactory(); _remotingClient = new SocketRemotingClient(string.Format("{0}.RemotingClient", Id), Setting.BrokerAddress, Setting.LocalAddress); _binarySerializer = ObjectContainer.Resolve <IBinarySerializer>(); _scheduleService = ObjectContainer.Resolve <IScheduleService>(); _allocateMessageQueueStragegy = ObjectContainer.Resolve <IAllocateMessageQueueStrategy>(); _executePullRequestWorker = new Worker(string.Format("{0}.ExecutePullRequest", Id), ExecutePullRequest); _handleMessageWorker = new Worker(string.Format("{0}.HandleMessage", Id), HandleMessage); _logger = ObjectContainer.Resolve <ILoggerFactory>().Create(GetType().FullName); _remotingClient.RegisterConnectionEventListener(new ConnectionEventListener(this)); }
public Consumer(string groupName, ConsumerSetting setting) { if (groupName == null) { throw new ArgumentNullException("groupName"); } GroupName = groupName; Setting = setting ?? new ConsumerSetting(); _lockObject = new object(); _subscriptionTopics = new Dictionary <string, HashSet <string> >(); _topicQueuesDict = new ConcurrentDictionary <string, IList <MessageQueue> >(); _pullRequestDict = new ConcurrentDictionary <string, PullRequest>(); _remotingClient = new SocketRemotingClient(Setting.BrokerAddress, Setting.SocketSetting, Setting.LocalAddress); _adminRemotingClient = new SocketRemotingClient(Setting.BrokerAdminAddress, Setting.SocketSetting, Setting.LocalAdminAddress); _binarySerializer = ObjectContainer.Resolve <IBinarySerializer>(); _scheduleService = ObjectContainer.Resolve <IScheduleService>(); _allocateMessageQueueStragegy = ObjectContainer.Resolve <IAllocateMessageQueueStrategy>(); _logger = ObjectContainer.Resolve <ILoggerFactory>().Create(GetType().FullName); _adminRemotingClient.RegisterConnectionEventListener(new ConnectionEventListener(this)); if (Setting.MessageHandleMode == MessageHandleMode.Sequential) { _consumingMessageQueue = new BlockingCollection <ConsumingMessage>(); _consumeMessageWorker = new Worker("ConsumeMessage", () => HandleMessage(_consumingMessageQueue.Take())); } _messageRetryQueue = new BlockingCollection <ConsumingMessage>(); }
public Consumer(string groupName, ConsumerSetting setting) { if (groupName == null) { throw new ArgumentNullException("groupName"); } GroupName = groupName; Setting = setting ?? new ConsumerSetting(); _lockObject = new object(); _subscriptionTopics = new List <string>(); _topicQueuesDict = new ConcurrentDictionary <string, IList <MessageQueue> >(); _pullRequestQueue = new BlockingCollection <PullRequest>(new ConcurrentQueue <PullRequest>()); _pullRequestDict = new ConcurrentDictionary <string, PullRequest>(); _messageRetryQueue = new BlockingCollection <ConsumingMessage>(new ConcurrentQueue <ConsumingMessage>()); _taskFactory = new TaskFactory(new LimitedConcurrencyLevelTaskScheduler(Setting.ConsumeThreadMaxCount)); _remotingClient = new SocketRemotingClient(Setting.BrokerAddress, Setting.SocketSetting, Setting.LocalAddress); _adminRemotingClient = new SocketRemotingClient(Setting.BrokerAdminAddress, Setting.SocketSetting, Setting.LocalAdminAddress); _binarySerializer = ObjectContainer.Resolve <IBinarySerializer>(); _scheduleService = ObjectContainer.Resolve <IScheduleService>(); _allocateMessageQueueStragegy = ObjectContainer.Resolve <IAllocateMessageQueueStrategy>(); _executePullRequestWorker = new Worker("ExecutePullRequest", ExecutePullRequest); _logger = ObjectContainer.Resolve <ILoggerFactory>().Create(GetType().FullName); _remotingClient.RegisterConnectionEventListener(new ConnectionEventListener(this)); }
public Consumer(string id, string groupName, ConsumerSetting setting) { if (id == null) { throw new ArgumentNullException("id"); } if (groupName == null) { throw new ArgumentNullException("groupName"); } Id = id; GroupName = groupName; Setting = setting ?? new ConsumerSetting(); _lockObject = new object(); _subscriptionTopics = new List <string>(); _topicQueuesDict = new ConcurrentDictionary <string, IList <MessageQueue> >(); _pullRequestQueue = new BlockingCollection <PullRequest>(new ConcurrentQueue <PullRequest>()); _pullRequestDict = new ConcurrentDictionary <string, PullRequest>(); _consumingMessageQueue = new BlockingCollection <ConsumingMessage>(new ConcurrentQueue <ConsumingMessage>()); _messageRetryQueue = new BlockingCollection <ConsumingMessage>(new ConcurrentQueue <ConsumingMessage>()); _handlingMessageDict = new ConcurrentDictionary <long, ConsumingMessage>(); _taskIds = new List <int>(); _taskFactory = new TaskFactory(new LimitedConcurrencyLevelTaskScheduler(Setting.ConsumeThreadMaxCount)); _remotingClient = new SocketRemotingClient(Setting.BrokerConsumerIPEndPoint, null, this); _binarySerializer = ObjectContainer.Resolve <IBinarySerializer>(); _scheduleService = ObjectContainer.Resolve <IScheduleService>(); _allocateMessageQueueStragegy = ObjectContainer.Resolve <IAllocateMessageQueueStrategy>(); _executePullRequestWorker = new Worker("Consumer.ExecutePullRequest", ExecutePullRequest); _handleMessageWorker = new Worker("Consumer.HandleMessage", HandleMessage); _logger = ObjectContainer.Resolve <ILoggerFactory>().Create(GetType().FullName); _waitSocketConnectHandle = new AutoResetEvent(false); }
public Consumer(string id, ConsumerSetting setting, string groupName) { Id = id; Setting = setting ?? new ConsumerSetting(); GroupName = groupName; _remotingClient = new SocketRemotingClient(Setting.BrokerAddress, Setting.BrokerPort); _binarySerializer = ObjectContainer.Resolve<IBinarySerializer>(); _scheduleService = ObjectContainer.Resolve<IScheduleService>(); _offsetStore = Setting.MessageModel == MessageModel.Clustering ? ObjectContainer.Resolve<IRemoteBrokerOffsetStore>() as IOffsetStore : ObjectContainer.Resolve<ILocalOffsetStore>() as IOffsetStore; _allocateMessageQueueStragegy = ObjectContainer.Resolve<IAllocateMessageQueueStrategy>(); _logger = ObjectContainer.Resolve<ILoggerFactory>().Create(GetType().Name); }
public RebalanceService(Consumer consumer, ClientService clientService, PullMessageService pullMessageService, CommitConsumeOffsetService commitConsumeOffsetService) { _consumer = consumer; _clientService = clientService; _clientId = clientService.GetClientId(); _pullRequestDict = new ConcurrentDictionary <string, PullRequest>(); _allocateMessageQueueStragegy = ObjectContainer.Resolve <IAllocateMessageQueueStrategy>(); _pullMessageService = pullMessageService; _commitConsumeOffsetService = commitConsumeOffsetService; _binarySerializer = ObjectContainer.Resolve <IBinarySerializer>(); _scheduleService = ObjectContainer.Resolve <IScheduleService>(); _logger = ObjectContainer.Resolve <ILoggerFactory>().Create(GetType().FullName); }
public RebalanceService(Consumer consumer, ClientService clientService, PullMessageService pullMessageService, CommitConsumeOffsetService commitConsumeOffsetService) { _consumer = consumer; _clientService = clientService; _clientId = clientService.GetClientId(); _pullRequestDict = new ConcurrentDictionary<string, PullRequest>(); _allocateMessageQueueStragegy = ObjectContainer.Resolve<IAllocateMessageQueueStrategy>(); _pullMessageService = pullMessageService; _commitConsumeOffsetService = commitConsumeOffsetService; _binarySerializer = ObjectContainer.Resolve<IBinarySerializer>(); _scheduleService = ObjectContainer.Resolve<IScheduleService>(); _logger = ObjectContainer.Resolve<ILoggerFactory>().Create(GetType().FullName); }
public Consumer(string id, string groupName, ConsumerSetting setting) { if (id == null) { throw new ArgumentNullException("id"); } if (groupName == null) { throw new ArgumentNullException("groupName"); } Id = id; GroupName = groupName; Setting = setting ?? new ConsumerSetting(); _remotingClient = new SocketRemotingClient(Setting.BrokerAddress, Setting.BrokerPort); _binarySerializer = ObjectContainer.Resolve<IBinarySerializer>(); _scheduleService = ObjectContainer.Resolve<IScheduleService>(); _localOffsetStore = ObjectContainer.Resolve<ILocalOffsetStore>(); _allocateMessageQueueStragegy = ObjectContainer.Resolve<IAllocateMessageQueueStrategy>(); _logger = ObjectContainer.Resolve<ILoggerFactory>().Create(GetType().FullName); }
public Consumer(string id, string groupName, ConsumerSetting setting) { if (id == null) { throw new ArgumentNullException("id"); } if (groupName == null) { throw new ArgumentNullException("groupName"); } Id = id; GroupName = groupName; Setting = setting ?? new ConsumerSetting(); _remotingClient = new SocketRemotingClient(Setting.BrokerAddress, Setting.BrokerPort); _binarySerializer = ObjectContainer.Resolve <IBinarySerializer>(); _scheduleService = ObjectContainer.Resolve <IScheduleService>(); _localOffsetStore = ObjectContainer.Resolve <ILocalOffsetStore>(); _allocateMessageQueueStragegy = ObjectContainer.Resolve <IAllocateMessageQueueStrategy>(); _logger = ObjectContainer.Resolve <ILoggerFactory>().Create(GetType().FullName); }
public Consumer(string id, string groupName, ConsumerSetting setting) { if (id == null) { throw new ArgumentNullException("id"); } if (groupName == null) { throw new ArgumentNullException("groupName"); } Id = id; GroupName = groupName; Setting = setting ?? new ConsumerSetting(); _lockObject = new object(); _subscriptionTopics = new List<string>(); _topicQueuesDict = new ConcurrentDictionary<string, IList<MessageQueue>>(); _pullRequestQueue = new BlockingCollection<PullRequest>(new ConcurrentQueue<PullRequest>()); _pullRequestDict = new ConcurrentDictionary<string, PullRequest>(); _consumingMessageQueue = new BlockingCollection<ConsumingMessage>(new ConcurrentQueue<ConsumingMessage>()); _messageRetryQueue = new BlockingCollection<ConsumingMessage>(new ConcurrentQueue<ConsumingMessage>()); _handlingMessageDict = new ConcurrentDictionary<long, ConsumingMessage>(); _taskIds = new List<int>(); _taskFactory = new TaskFactory(new LimitedConcurrencyLevelTaskScheduler(Setting.ConsumeThreadMaxCount)); _remotingClient = new SocketRemotingClient(Setting.BrokerConsumerIPEndPoint, null, this); _binarySerializer = ObjectContainer.Resolve<IBinarySerializer>(); _scheduleService = ObjectContainer.Resolve<IScheduleService>(); _allocateMessageQueueStragegy = ObjectContainer.Resolve<IAllocateMessageQueueStrategy>(); _executePullRequestWorker = new Worker("Consumer.ExecutePullRequest", ExecutePullRequest); _handleMessageWorker = new Worker("Consumer.HandleMessage", HandleMessage); _logger = ObjectContainer.Resolve<ILoggerFactory>().Create(GetType().FullName); _waitSocketConnectHandle = new AutoResetEvent(false); }