public void Handle(OrderPlaced message) { var midget = MidgetFactory.Create(message.IsDodgyCustomer, _topicBasedPubSub); _midgets[message.CorellationId] = midget; _topicBasedPubSub.SubscribeByCorellationId <OrderPlaced>(message.CorellationId, midget); _topicBasedPubSub.SubscribeByCorellationId <OrderCooked>(message.CorellationId, midget); _topicBasedPubSub.SubscribeByCorellationId <CookingTimedOut>(message.CorellationId, midget); _topicBasedPubSub.SubscribeByCorellationId <OrderPriced>(message.CorellationId, midget); _topicBasedPubSub.SubscribeByCorellationId <OrderPaid>(message.CorellationId, midget); midget.Handle(message); }
public static void Main() { var horn = new ConsoleHorn(); var topicBasedPubSub = new TopicBasedPubSub(); var wireUpResult = WireUp(topicBasedPubSub); wireUpResult.Startables.ForEach(x => x.Start()); StartPrintingQueueStats(horn, wireUpResult.Trackables, wireUpResult.StatsProjection); topicBasedPubSub.SubscribeByType(wireUpResult.MidgetHouse); var ordersCount = 10; for (var i = 0; i < ordersCount; ++i) { var isDrinker = i % 2 == 0; var orderId = Guid.NewGuid(); topicBasedPubSub.SubscribeByCorellationId(orderId, new MessageTracer(orderId.ToString("N"))); wireUpResult.Waiter .PlaceNewOrder(orderId, new Dictionary <string, int> { { isDrinker?GoodsMenu.Drinkables.Vodka: GoodsMenu.Eatables.Meat, 2 } }); horn.Say($"[outer user]: got order handle {orderId}."); } horn.Say("[outer user]: placed all orders."); Console.ReadKey(false); }