예제 #1
0
        static void Main(string[] args)
        {
            DataBus bus = null;

            DependencyResolver.SetDependencyResolver(new NinjectBusDependencyResolver());
            try
            {
                EndpointConvention.Map <TestMessage>(new Uri("rabbitmq://localhost/testmessage_queue"));
                MessageCorrelation.UseCorrelationId <TestMessage>(x => x.CorrelationId);
                bus = new DataBus("domer");
                bus.Start();

                for (int i = 0; i < MessageCount; i++)
                {
                    bus.Publish <TestMessage>(new TestMessage()
                    {
                        Message = $"Hello World{i}"
                    }).Wait();
                }

                //Thread.Sleep(TimeSpan.FromSeconds(20));
                Console.WriteLine($"Количество обработанных сообщений: {TestMessageHandler.Counter}");
                Console.WriteLine($"Время затрачено: {TestMessageHandler.WorkTime}");
                Console.ReadLine();
            }
            finally
            {
                bus?.Stop();
            }
        }