예제 #1
0
        static void Send()
        {
            var rand = new Random();
            var bus  = RabbitHutch.CreateBus("host=localhost");

            while (true)
            {
                var message = new MyMessage
                {
                    Name     = rand.RandomString(),
                    ShoeSize = rand.Next(1, 20)
                };
                var myOtherMessage = new MyOtherMessage
                {
                    Address = "123 " + rand.RandomString() + " Street",
                    Taxes   = Convert.ToDecimal(rand.NextDouble())
                };

                // this messages will be put in the queue even if there aren't any receivers yet
                bus.Send("my.queue", message);
                bus.Send("my.queue", myOtherMessage);
                Console.WriteLine("Sent two different messages!");
                Thread.Sleep(1000);
            }
        }
예제 #2
0
        static void Send()
        {
            var bus  = RabbitHutch.CreateBus("host=localhost");
            var rand = new Random();

            while (true)
            {
                var myMessage = new MyMessage
                {
                    body    = "this is MyMessage body",
                    someVal = rand.Next(1, 20)
                };
                var myOtherMessage = new MyOtherMessage
                {
                    body             = "this is MyOtherMessage body",
                    MyOtherMessageId = rand.Next(1, 20)
                };
                //these messages will be put in a queue even if there aren't any receivers yet.
                //Queue created automatically.
                bus.Send("my.queue", myMessage);
                bus.Send("my.queue", myOtherMessage);
                Console.WriteLine("Sent two different messages.");
                Thread.Sleep(1000);
            }
        }