Esempio n. 1
0
        private static IEventBus InitializeEventBus(InMemoryBufferedBrowsableElementStore buffer)
        {
            var bus = new InProcessEventBus();

            bus.RegisterHandler(new InMemoryBufferedEventHandler(buffer));

            return bus;
        }
Esempio n. 2
0
        public static void BootUp(InMemoryBufferedBrowsableElementStore buffer)
        {
            var config = new Ncqrs.Config.StructureMap.StructureMapConfiguration(cfg =>
            {
                cfg.For<ICommandService>().Use(InitializeCommandService);
                cfg.For<IEventBus>().Use(x => InitializeEventBus(buffer));
                cfg.For<IEventStore>().Use(InitializeEventStore);
                cfg.For<IKnownCommandsEnumerator>().Use(new AllCommandsInAppDomainEnumerator());
            });

            NcqrsEnvironment.Configure(config);
        }
Esempio n. 3
0
        static void Main(string[] args)
        {
            var bus = new InProcessEventBus(true);
            bus.RegisterAllHandlersInAssembly(typeof(Program).Assembly);
            var browsableEventStore = new MsSqlServerEventStoreElementStore(Settings.Default.EventStoreConnectionString);
            var buffer = new InMemoryBufferedBrowsableElementStore(browsableEventStore, 20 /*magic number faund in ThresholedFetchPolicy*/);
            var pipeline = Pipeline.Create("Default", new EventBusProcessor(bus), buffer);

            BootStrapper.BootUp(buffer);
            var commandServiceHost = new ServiceHost(typeof(CommandWebService));

            commandServiceHost.Open();
            pipeline.Start();

            Console.ReadLine();

            pipeline.Stop();
            commandServiceHost.Close();
        }
Esempio n. 4
0
        private static void ConfigureNcqrsEnvironment(InMemoryBufferedBrowsableElementStore buffer)
        {
            var eventStoreConnectionString = ConfigurationManager.ConnectionStrings["MyNotes Event Store"].ConnectionString;
            var eventStore = new MsSqlServerEventStore(eventStoreConnectionString);

            Assembly domainAssembly = Assembly.LoadFrom("MyNotes.Domain.dll");

            IWindsorContainer container = new WindsorContainer();
            container.AddFacility("ncqrs.ds", new DynamicSnapshotFacility(domainAssembly));
            container.Register(
                Component.For<ISnapshottingPolicy>().ImplementedBy<SimpleSnapshottingPolicy>(),
                Component.For<ICommandService>().Instance(InitializeCommandService()),
                Component.For<IEventBus>().Instance(InitializeEventBus(buffer)),
                Component.For<IEventStore>().Forward<ISnapshotStore>().Instance(eventStore),
                Component.For<IKnownCommandsEnumerator>().Instance(new AllCommandsInAppDomainEnumerator()),
                Component.For<Note>().AsSnapshotable());

            WindsorConfiguration config = new WindsorConfiguration(container);

            NcqrsEnvironment.Configure(config);
        }
Esempio n. 5
0
        static void Main(string[] args)
        {
            Console.WindowHeight = 30;
            Console.WindowWidth = 150;

            var bus = new InProcessEventBus(true);
            var eventStore = Program.GetBrowsableEventStore();
            var buffer = new InMemoryBufferedBrowsableElementStore(eventStore, 20 /*magic number found in ThresholdFetchPolicy*/);

            bus.RegisterAllHandlersInAssembly(typeof(MyNotes.Denormalizers.NoteDenormalizer).Assembly);
            BootStrapper.BootUp(buffer);

            var pipeline = Pipeline.Create("Default", new EventBusProcessor(bus), buffer);
            pipeline.Start();

            var commandServiceHost = new ServiceHost(typeof(CommandWebService));
            commandServiceHost.Open();

            Console.ReadLine();

            commandServiceHost.Close();
            pipeline.Stop();
        }
Esempio n. 6
0
 public static void BootUp(InMemoryBufferedBrowsableElementStore buffer)
 {
     ConfigureNcqrsEnvironment(buffer);
 }
 public InMemoryBufferedEventHandler(InMemoryBufferedBrowsableElementStore buffer)
 {
     _buffer = buffer;
 }