Esempio n. 1
0
        public static void Main(string[] args)
        {
            var logger = new NullLogger();
            bus = RabbitHutch.CreateBus("host=localhost", x => x.Register<IEasyNetQLogger>((y) => logger));

            bus.Subscribe<SimpleMessage<string>>("Responder", HandleMessage);

            Console.ReadLine();
            bus.Dispose();
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            Console.WriteLine("Press enter to start!");
            Console.ReadLine();

            var logger = new NullLogger();
            int i = 1000;
            var bus = RabbitHutch.CreateBus("host=localhost", x => x.Register<IEasyNetQLogger>((y) => logger));
            var rand = new Random();
            data = new TestDataContainer();
            bus.Subscribe<SimpleResponse>("LoadTest", HandleResponse);

            while (i > 0)
            {
                var message = new SimpleMessage<string>(String.Format("Message {0}", i), Guid.NewGuid());

                data.AddOrUpdate(new TestData() { CorrelationId = message.CorrelationId, StartTime = DateTime.UtcNow });
                bus.Publish<Messages.SimpleMessage<string>>(message);
                //System.Threading.Thread.Sleep(rand.Next(1000));
                i--;
            }
            while (!data.collectionUpdated)
            {
                System.Threading.Thread.Sleep(100);
            }

            data.OutputResults();

            i = 2000;
            while (i > 1000)
            {
                var message = new SimpleMessage<string>(String.Format("Message {0}", i), Guid.NewGuid());

                data.AddOrUpdate(new TestData() { CorrelationId = message.CorrelationId, StartTime = DateTime.UtcNow });
                //System.Threading.Thread.Sleep(rand.Next(1000));
                bus.Publish<Messages.SimpleMessage<string>>(message);

                i--;
            }
            while (!data.collectionUpdated)
            {
                System.Threading.Thread.Sleep(100);
            }

            data.OutputResults();

            Console.ReadLine();
            bus.Dispose();
        }
        static void Main(string[] args)
        {
            var logger = new NullLogger();
            bus = RabbitHutch.CreateBus("host=localhost", x => x.Register<IEasyNetQLogger>((y) => logger));

            var data = Enumerable.Range(1, 5).Select(x => x.ToString()).ToList();

            bus.Subscribe<Message1>("First", HandleMessage);
            bus.SubscribeAsync<Message2>("Second", x => Task.Factory.StartNew(() => AnotherMessage(x)));
            Console.ReadLine();
            bus.Publish(new Message1() { data = data });

            Console.ReadLine();
            bus.Dispose();
        }