Esempio n. 1
0
        private Configuration_Read()
        {
            _ebus = new EventBus();
            //REgistering my Events to corresponding EventHandlers
            var infoProjection = new UsersEventHandler();

            _ebus.RegisterHandler <UserCreatedEvent>(infoProjection.Handle);
            _ebus.RegisterHandler <UserUpdatedEvent>(infoProjection.Handle);

            _readModel = new ReadModelFacade(infoProjection);
            RabbitMQSubscription();
        }
Esempio n. 2
0
        public void Configuration(IAppBuilder app)
        {
            IMessageHandler messageHandler = null;

            IMessageBus messageBus = new ImmediateMessageBus(
                new Lazy <IMessageHandler>(() => messageHandler));

            var serializer = new JsonMessageSerializer();

            Func <TodoListEventStoreDbContext> dbContextFactory = () =>
            {
                var context = new TodoListEventStoreDbContext();
                context.Database.Log += m => Debug.WriteLine(m);
                return(context);
            };

            IEventSourcedRepository <Domain.TodoItem> repository =
                new SqlEventSourcedRepository <Domain.TodoItem>(
                    new SqlEventStore(
                        dbContextFactory,
                        serializer),
                    new SqlEventPublisher(
                        dbContextFactory,
                        serializer,
                        messageBus),
                    new SqlMementoStore(
                        dbContextFactory,
                        serializer),
                    Domain.TodoItem.Factory,
                    Domain.TodoItem.Factory);

            messageHandler = new CompositeMessageHandler(
                new TodoItemCommandHandler(repository),
                new ReadModelGenerator(() => new ReadModelDbContext()));

            IReadModelFacade readModelFacade =
                new ReadModelFacade(() => new ReadModelDbContext());

            app.Use(async(context, next) =>
            {
                context.Set(nameof(IMessageBus), messageBus);
                context.Set(nameof(IReadModelFacade), readModelFacade);
                await next.Invoke();
            });

            var properties = new AppProperties(app.Properties);

            repository.EventPublisher.EnqueueAll(properties.OnAppDisposing);
        }
Esempio n. 3
0
        private Configuration()
        {
            _bus = new MessageBus();
            var eventStore = new SqlEventStore(_bus);
            var repository = new DomainRepository(eventStore);

            var commandService = new AccountApplicationService(repository);

            _bus.RegisterHandler <RegisterAccountCommand>(commandService.Handle);
            _bus.RegisterHandler <DebitAccountCommand>(commandService.Handle);
            _bus.RegisterHandler <UnlockAccountCommand>(commandService.Handle);

            var infoProjection = new AccountInfoProjection();

            _bus.RegisterHandler <AccountRegisteredEvent>(infoProjection.Handle);
            _bus.RegisterHandler <AccountLockedEvent>(infoProjection.Handle);
            _bus.RegisterHandler <AccountUnlockedEvent>(infoProjection.Handle);

            var balanceProjection = new AccountBalanceProjection();

            _bus.RegisterHandler <AccountRegisteredEvent>(balanceProjection.Handle);
            _bus.RegisterHandler <AccountDebitedEvent>(balanceProjection.Handle);

            var notification = new NotificationProjection();

            _bus.RegisterHandler <AccountRegisteredEvent>(notification.Handle);
            _bus.RegisterHandler <AccountDebitedEvent>(notification.Handle);
            _bus.RegisterHandler <AccountLockedEvent>(notification.Handle);
            _bus.RegisterHandler <AccountUnlockedEvent>(notification.Handle);
            _bus.RegisterHandler <OverdrawAttemptedEvent>(notification.Handle);

            _readModel = new ReadModelFacade(balanceProjection, infoProjection, notification);

            var events = eventStore.GetAllEventsEver();

            _bus.Publish(events);
        }
Esempio n. 4
0
 public HomeController()
 {
     _bus = ServiceLocator.Bus;
     _readmodel = new ReadModelFacade();
 }
Esempio n. 5
0
 public HomeController()
 {
     _bus       = ServiceLocator.Bus;
     _readmodel = new ReadModelFacade();
 }
Esempio n. 6
0
 public HomeController(FakeBus bus, ReadModelFacade readmodel)
 {
     _bus       = bus;
     _readmodel = readmodel;
 }
Esempio n. 7
0
 public HomeController()
 {
     _commandService = IocContainer.Container.Resolve <ICommandSender>();
     _readmodel      = new ReadModelFacade();
 }
 public InventoryItemController()
 {
     _bus = Global._bus;
     _readmodel = new ReadModelFacade();
 }
 public InventoryItemController()
 {
     _bus       = Global._bus;
     _readmodel = new ReadModelFacade();
 }
 public MicroserviceController(CommandBus bus, ReadModelFacade readServicesFacade)
 {
     this.readFacade = readServicesFacade;
     this.bus        = bus;
 }