示例#1
0
        static void Main(string[] args)
        {
            var bus = new RabbitMqBus();

            DoPriceHandler(bus);
            DoProductHandler(bus);
            for (int i = 1; i <= 10; i++)
            {
                Thread.Sleep(500);
                if (i % 2 == 0)
                {
                    bus.Publish(new PriceMessage
                    {
                        ProductID = i,
                        NewPrice  = i * 400,
                        OldPrice  = new Random().Next(10, 20) * i
                    });
                }
                else
                {
                    bus.Publish(new ProductMessage
                    {
                        Amount = 200,
                        Name   = $"Product {i}"
                    });
                }
            }
            Console.ReadKey();
        }