Ejemplo n.º 1
0
        public static void HandleMessage(SimpleMessage<string> message)
        {
            Console.WriteLine("Responding to message: {0}", message.Message);

            bus.Publish(new SimpleResponse()
            {
                Message = message.Message,
                CorrelationId = message.CorrelationId
            });
        }
Ejemplo 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();
        }
		public void A_message_is_published_to_the_local_bus()
		{
			Message = new SimpleMessage();

			LocalBus.Publish(Message);
		}
		public void A_message_is_sent_to_the_bus_endpoint()
		{
			Message = new SimpleMessage();

			LocalBus.Endpoint.Send(Message);
		}