public void Start() { Broker[] brokers = config.GetBrokers(); int consumerCount = config.consumerCount; if (brokers.Length < 1 || consumerCount < 1) { return; } this.brokerConsumerThreads = new ConsumerThread[brokers.Length][]; for (int i = 0; i < brokers.Length; i++) { ConsumerThread[] threads = new ConsumerThread[consumerCount]; this.brokerConsumerThreads[i] = threads; for (int j = 0; j < consumerCount; j++) { ServiceConfig myConfig = (ServiceConfig)this.config.Clone(); myConfig.broker = brokers[i]; ConsumerThreadStart start = new ConsumerThreadStart(myConfig); ConsumerThread thread = new ConsumerThread(start); thread.Start(); threads[j] = thread; } } log.InfoFormat("Service({0}) started", config.mq); }
public void Dispose() { if (this.brokerConsumerThreads != null) { for (int i = 0; i < brokerConsumerThreads.Length; i++) { ConsumerThread[] threads = brokerConsumerThreads[i]; for (int j = 0; j < threads.Length; j++) { ConsumerThread thread = threads[j]; thread.Dispose(); } } } }