Ejemplo n.º 1
0
        public void Run()
        {
            var producers = new List<Producer>();
            var consumers = new List<Consumer>();

            for (int i = 0; i < 1; i++)
            {
                var producer = new Producer(new List<string>(new string[] {"1", "2", "3"}));
                producers.Add(producer);
                producer.Start();
                var consumer = new Consumer(producer);
                consumer.Start();
                consumers.Add(consumer);
            }

            try
            {
                Console.ReadLine();
                ExitMessage = Guid.NewGuid().ToString();
                foreach (var producer in producers)
                    Manager.Send(QueueName, ExitMessage);
            }
            finally
            {

                foreach (var producer in producers)
                    producer.Stop();
                foreach (var consumer in consumers)
                    consumer.Stop();
            }
            for (int i = 0; i < producers.Count; i++)
            {
                var p = producers[i];
                Console.WriteLine(i);
                ReportStats(p.MessageCount);
                ReportStats(consumers[i].MessageCount);
            }
        }
Ejemplo n.º 2
0
 public Consumer(Producer producer)
 {
     _producer = producer;
 }