Beispiel #1
0
        private static void Bootstrap()
        {
            var aggregateContext = Aggregates.CreateWith(new InMemoryEventStore());
            var processContext   = ProcessContext.CreateWith(new InMemoryEventStore());

            _productsInStockReadModel = new List <ProductInStock>();

            var products = new ProductCommandHandler(aggregateContext);
            var orders   = new OrderCommandHandler(aggregateContext);

            var sideEffects = new SideEffects();

            var readModelHandler     = new ProductReadModelEventHandler(_productsInStockReadModel);
            var orderProcessRouter   = new OrderProcessRouter(processContext);
            var pickingProcessRouter = new PickingProcessRouter(processContext);

            aggregateContext
            .PublishNewStateTo(readModelHandler)
            .And(orderProcessRouter)
            .And(pickingProcessRouter);

            processContext
            .DispatchCommandsTo(products)
            .And(sideEffects);

            _commandHandlers = Dispatch <IAmACommandMessage>
                               .To(products)
                               .And(orders);
        }