private static void Main() { /////setup XmlConfigurator.ConfigureAndWatch(new FileInfo("log4net.xml")); WindsorContainer c = new DefaultMassTransitContainer(); IEndpointFactory ef = EndpointFactoryConfigurator.New(e => e.RegisterTransport <MsmqEndpoint>()); c.Kernel.AddComponentInstance("endpointFactory", typeof(IEndpointFactory), ef); c.AddComponent <SimpleMessageHandler>(); c.AddComponentLifeStyle("counter", typeof(Counter), LifestyleType.Singleton); c.AddComponentLifeStyle("rvaoeuaoe", typeof(CacheUpdateResponseHandler), LifestyleType.Transient); IServiceBus bus = ServiceBusConfigurator.New(b => { b.ReceiveFrom("msmq://localhost/mt_client"); b.ConfigureService <SubscriptionClientConfigurator>(sc => sc.SetSubscriptionServiceEndpoint("msmq://localhost/mt_subscriptions")); b.ConfigureService <HealthClientConfigurator>(hc => hc.SetHeartbeatInterval(10)); }); c.Kernel.AddComponentInstance("bus", typeof(IServiceBus), bus); bus.Subscribe <CacheUpdateResponseHandler>(); bus.Subscribe <SimpleMessageHandler>(); IEndpoint ep = c.Resolve <IEndpointFactory>().GetEndpoint(new Uri("msmq://localhost/mt_subscriptions")); var subTester = new SubscriptionServiceTester(ep, bus, c.Resolve <Counter>()); var healthTester = new HealthServiceTester(c.Resolve <Counter>(), bus); var timeoutTester = new TimeoutTester(bus); bus.Subscribe(healthTester); /////// Console.WriteLine("Please enter the number of hours you would like this test to run for?"); Console.WriteLine("(use 0.1 for 6 minutes)"); Console.WriteLine("(use 0.016 for 1 minute)"); string input = Console.ReadLine(); double hours = double.Parse(input ?? "0"); DateTime stopTime = DateTime.Now.AddHours(hours); Console.WriteLine("Test Started"); var rand = new Random(); while (DateTime.Now < stopTime) { subTester.Test(); healthTester.Test(); timeoutTester.Test(); Thread.Sleep(rand.Next(5, 10) * 1000); PrintTime(bus, c.Resolve <Counter>()); } //print final stuff (probably do this by tester) subTester.Results(); Console.WriteLine("Done (press any key to exit)"); Console.ReadKey(true); }
private static void Main() { /////setup XmlConfigurator.ConfigureAndWatch(new FileInfo("log4net.xml")); WindsorContainer c = new WindsorContainer(); c.AddComponent <SimpleMessageHandler>(); c.AddComponentLifeStyle("counter", typeof(Counter), LifestyleType.Singleton); c.AddComponentLifeStyle("rvaoeuaoe", typeof(CacheUpdateResponseHandler), LifestyleType.Transient); var bus = ServiceBusFactory.New(sbc => { sbc.UseMsmq(); sbc.VerifyMsDtcConfiguration(); sbc.VerifyMsmqConfiguration(); sbc.ReceiveFrom("msmq://localhost/mt_client"); sbc.UseSubscriptionService("msmq://localhost/mt_subscriptions"); sbc.UseHealthMonitoring(10); sbc.Subscribe(subs => { subs.LoadFrom(c); }); }); c.Register(Component.For <IServiceBus>().Instance(bus)); IEndpoint ep = bus.GetEndpoint(new Uri("msmq://localhost/mt_subscriptions")); var subTester = new SubscriptionServiceTester(ep, bus, c.Resolve <Counter>()); var healthTester = new HealthServiceTester(c.Resolve <Counter>(), bus); var timeoutTester = new TimeoutTester(bus); bus.SubscribeInstance(healthTester); /////// Console.WriteLine("Please enter the number of hours you would like this test to run for?"); Console.WriteLine("(use 0.1 for 6 minutes)"); Console.WriteLine("(use 0.016 for 1 minute)"); string input = Console.ReadLine(); double hours = double.Parse(input ?? "0"); DateTime stopTime = DateTime.Now.AddHours(hours); Console.WriteLine("Test Started"); var rand = new Random(); while (DateTime.Now < stopTime) { subTester.Test(); healthTester.Test(); timeoutTester.Test(); Thread.Sleep(rand.Next(5, 10) * 1000); PrintTime(bus, c.Resolve <Counter>()); } //print final stuff (probably do this by tester) subTester.Results(); Console.WriteLine("Done (press any key to exit)"); Console.ReadKey(true); }