protected override void ConfigureApplicationContainer(TinyIoCContainer container) { var viewmodel = new InMemoryViewModelRepository(); var snapshotPath = ConfigurationManager.AppSettings["snapshotPath"]; var snapshotVersion = ConfigurationManager.AppSettings["snapshotVersion"]; var streamName = ConfigurationManager.AppSettings["streamName"]; var snapshottingDispatcher = new ProtoBufSnapshottingResolvedEventDispatcher(() => { var repo = (container.Resolve <IViewModelReader>() as InMemoryViewModelRepository); return(GetPairs(repo)); }, snapshotPath, snapshotVersion); var items = snapshottingDispatcher.LoadObjects(); int?startingEvent = snapshottingDispatcher.LoadCheckpoint(); //add the items to the viewmodel foreach (var dynamicItem in items.Select(item => item as dynamic)) { viewmodel.Add(dynamicItem.Key, dynamicItem.Value); } ViewModelLoaded(viewmodel); //event store var esLogger = new EventStoreLogaryLogger(); var conn = SetUpEventStoreConnection("EventStoreConnection", esLogger); container.Register(conn); //aggregate repository container.Register <IAggregateRepository, EventStoreAggregateRepository>(); container.Register <IViewModelReader>(viewmodel); container.Register <IViewModelWriter>(viewmodel); var multiplexingDispatcher = new MultiplexingDispatcher <ResolvedEvent>(GetDispatchers(container).ToArray()); snapshottingDispatcher.InnerDispatcher = multiplexingDispatcher; var loggingDispatcher = new ErrorLoggingDispatcher(snapshottingDispatcher, false); container.Register <IDispatcher <ResolvedEvent> >(loggingDispatcher); var subscriber = new EventStoreSubscriber(conn, loggingDispatcher, streamName, esLogger, startingEvent, 4096, 70000); container.Register(subscriber); }
static void Main(string[] args) { var eventStoreSubscriber = new EventStoreSubscriber("tcp://localhost:1113", "Library"); var bookAddedEventsSubscription = eventStoreSubscriber.SubscribeToEventsOfType <BookAdded>(); var allBooksEventsSubscription = eventStoreSubscriber.SubscribeToAggregateTypeEvents <Book>(); var book1Events = eventStoreSubscriber.SubscribeToAggregateEvents(BookId.BookIdFrom("1")); using (new DomainEventStreamConsoleConsumer(nameof(bookAddedEventsSubscription), bookAddedEventsSubscription.Stream, "")) using (new DomainEventStreamConsoleConsumer(nameof(allBooksEventsSubscription), allBooksEventsSubscription.Stream, "\t\t\t\t\t\t\t\t\t")) using (new DomainEventStreamConsoleConsumer(nameof(book1Events), book1Events.Stream, "\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t")) { Console.ReadLine(); bookAddedEventsSubscription.Stop(); allBooksEventsSubscription.Stop(); book1Events.Stop(); } }