Beispiel #1
0
        static void Main(string[] args)
        {
            var connectionFactory = new ConnectionFactory {
                HostName = "localhost"
            };
            var eventBus = new RabbitMQEventBus(connectionFactory, "EventBus.RabbitMQ.Events.Exchange", queueName: "EventBus.RabbitMQ.Events.Queue");

            var sendedEvent = new SendedEvent("优惠");

            Console.WriteLine($"商店发了{sendedEvent.Name}通知!");
            eventBus.Publish <SendedEvent>(sendedEvent);

            Console.ReadKey();
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            var sendedEvent = new SendedEvent("优惠");
            var busControl  = Bus.Factory.CreateUsingRabbitMq();

            busControl.Start();
            try
            {
                Console.WriteLine($"商店发了{sendedEvent.Name}通知!");
                busControl.Publish(sendedEvent);
                Console.ReadKey();
            }
            finally
            {
                busControl.Stop();
            }
        }