protected override void DoSetUp() { // this one is in DMZ pricedeskInputQueue = "test.pricedesk.input"; pricedesk = CreateBus(pricedeskInputQueue, new HandlerActivatorForTesting()); // and this one is inside ordersystemInputQueue = "test.ordersystem.input"; orderSystemHandlerActivator = new HandlerActivatorForTesting(); ordersystem = CreateBus(ordersystemInputQueue, orderSystemHandlerActivator); // so we set up a one-way gateway service on each side: gatewayInDmz = new GatewayService { ListenQueue = "test.rebus.dmz.gateway", DestinationUri = "http://localhost:18080", }; gatewayInside = new GatewayService { ListenUri = "http://+:18080", DestinationQueue = ordersystemInputQueue }; gatewayInDmz.Start(); gatewayInside.Start(); pricedesk.Start(1); ordersystem.Start(1); }
protected override void DoSetUp() { RebusLoggerFactory.Current = new ConsoleLoggerFactory(false) { MinLevel = LogLevel.Info }; // this one is in DMZ priceDeskInputQueue = "test.pricedesk.input"; priceDeskHandlerActivator = new HandlerActivatorForTesting(); priceDesk = CreateBus(priceDeskInputQueue, priceDeskHandlerActivator); // and this one is inside orderSystemInputQueue = "test.ordersystem.input"; orderSystemHandlerActivator = new HandlerActivatorForTesting(); orderSystem = CreateBus(orderSystemInputQueue, orderSystemHandlerActivator); priceDeskGatewayInputQueue = "test.rebus.pricedesk.gateway"; MsmqUtil.PurgeQueue(priceDeskGatewayInputQueue); orderSystemGatewayInputQueue = "test.rebus.ordersystem.gateway"; MsmqUtil.PurgeQueue(orderSystemGatewayInputQueue); // so we set up a one-way gateway service on each side: // - the outbound is on the DMZ side priceDeskGatewayService = new GatewayService { ListenQueue = priceDeskGatewayInputQueue, DestinationUri = "http://localhost:" + TestCategories.AvailableHttpPort, }; // and the inbound is on the network domain side orderSystemGatewayService = new GatewayService { ListenUri = "http://+:" + TestCategories.AvailableHttpPort, DestinationQueue = orderSystemInputQueue, }; priceDeskGatewayService.Start(); orderSystemGatewayService.Start(); priceDesk.Start(1); orderSystem.Start(1); }
protected override void DoSetUp() { RebusLoggerFactory.Current = new ConsoleLoggerFactory(false) { MinLevel = LogLevel.Warn }; // this one is in DMZ pricedeskInputQueue = "test.pricedesk.input"; pricedesk = CreateBus(pricedeskInputQueue, new HandlerActivatorForTesting()); // and this one is inside ordersystemInputQueue = "test.ordersystem.input"; orderSystemHandlerActivator = new HandlerActivatorForTesting(); ordersystem = CreateBus(ordersystemInputQueue, orderSystemHandlerActivator); outboundListenQueue = "test.rebus.dmz.gateway"; MsmqUtil.PurgeQueue(outboundListenQueue); // so we set up a one-way gateway service on each side: // - the outbound is on the DMZ side outbound = new GatewayService { ListenQueue = outboundListenQueue, DestinationUri = "http://localhost:8080", }; // and the inbound is on the network domain side inbound = new GatewayService { ListenUri = "http://+:8080", DestinationQueue = ordersystemInputQueue }; outbound.Start(); inbound.Start(); pricedesk.Start(1); ordersystem.Start(1); }
protected override void DoSetUp() { RebusLoggerFactory.Current = new ConsoleLoggerFactory(false) { MinLevel = LogLevel.Warn }; MsmqUtil.Delete(PriceDeskInputQueue); MsmqUtil.Delete(OrderSystemInputQueue); MsmqUtil.Delete(GatewayListeningQueue); // this one is in DMZ pricedesk = CreateBus(PriceDeskInputQueue, new HandlerActivatorForTesting()); // and this one is inside orderSystemHandlerActivator = new HandlerActivatorForTesting(); ordersystem = CreateBus(OrderSystemInputQueue, orderSystemHandlerActivator); // so we set up a one-way gateway service on each side: gatewayInDmz = new GatewayService { ListenQueue = GatewayListeningQueue, DestinationUri = "http://localhost:18080", }; gatewayInside = new GatewayService { ListenUri = "http://+:18080", DestinationQueue = OrderSystemInputQueue }; gatewayInDmz.Start(); gatewayInside.Start(); pricedesk.Start(1); ordersystem.Start(1); }
public void WhenInboundHasProblemsOutboundJustKeepsOnTrucking(int numberOfMessages) { // arrange var receivedMessageCount = 0; var messageTracker = new ConcurrentDictionary <Guid, int>(); var resetEvent = new ManualResetEvent(false); orderSystemHandlerActivator.Handle <PlaceOrderRequest>(req => { if (req.What != "beer" || req.HowMuch != 12) { return; } OnCommit.Do(() => { messageTracker.AddOrUpdate(req.MsgId, 1, (id, count) => count + 1); var newValue = Interlocked.Increment(ref receivedMessageCount); if (newValue >= numberOfMessages) { resetEvent.Set(); } }); }); var timeout = numberOfMessages.Seconds(); var keepMakingChaos = true; var chaosMonkey = new Thread(() => { while (keepMakingChaos) { Thread.Sleep(0.1.Seconds()); inbound.Stop(); Console.WriteLine("Inbound stopped - {0} messages processed...", receivedMessageCount); Thread.Sleep(0.2.Seconds()); inbound.Start(); Thread.Sleep(2.2331.Seconds()); } }); // act chaosMonkey.Start(); numberOfMessages.Times(() => pricedesk.Send(CreateMessage())); // assert var resetEventWasSet = resetEvent.WaitOne(timeout + 5.Seconds()); keepMakingChaos = false; chaosMonkey.Join(); // chill, be more sure to empty the queue completely Thread.Sleep(1.Seconds()); Assert.That(resetEventWasSet, Is.True, "Request was not received in order system within timeout of {0}", timeout); receivedMessageCount.ShouldBeGreaterThanOrEqualTo(numberOfMessages); Console.WriteLine("Actual number of received messages: {0}", receivedMessageCount); if (messageTracker.Any(t => t.Value > 1)) { Console.WriteLine(@"The following IDs were received more than once: {0}", string.Join(Environment.NewLine, messageTracker.Where(t => t.Value > 1).Select(kvp => " " + kvp.Key + ": " + kvp.Value))); } messageTracker.Count.ShouldBe(numberOfMessages); }