public async Task SnapshotBehavior_Generic_Generic_Shouldnt_Be_Used_If_Set_To_Disabled() { try { DeleteAll(); Guid aggId = Guid.NewGuid(); var store = new EFEventStore(GetOptions(behavior: SnapshotEventsArchiveBehavior.Disabled)); for (int i = 0; i < 11; i++) { var evt = new AggregateSnapshotEvent(aggId); await store.StoreDomainEventAsync(evt); } using (var ctx = GetContext()) { ctx.Set <Event>().Count().Should().Be(11); var evt = ctx.Set <Event>().ToList().OrderByDescending(e => e.EventTime).FirstOrDefault(); evt.Should().NotBeNull(); evt.HashedAggregateId.Should().Be(aggId.ToJson(true).GetHashCode()); evt.Sequence.Should().Be(11); evt.EventData.Should().NotBeNullOrWhiteSpace(); ctx.Set <Snapshot>().Count().Should().Be(0); } } finally { DeleteAll(); } }
public async Task GetAllEventsByAggregateType_Should_Returns_AllConcernedEvents() { try { DeleteAll(); var store = new EFEventStore(GetOptions()); List <IDomainEvent> events = new List <IDomainEvent>(); var aggAId = Guid.NewGuid(); var aggBId = Guid.NewGuid(); for (int i = 0; i < 100; i++) { if (i % 2 == 0) { events.Add(new EventAggA(aggAId)); } else { events.Add(new EventAggB(aggBId)); } } await store.StoreDomainEventRangeAsync(events); var store2 = new EFEventStore(GetOptions()); (await store2.GetAllEventsByAggregateType(typeof(AggA)).ToListAsync()).Should().HaveCount(50); (await store2.GetAllEventsByAggregateType(typeof(AggB)).ToListAsync()).Should().HaveCount(50); } finally { DeleteAll(); } }
public async Task GetAllEventsByEventType_Generic_Should_Returns_OnlyConcernedEvents() { try { DeleteAll(); var store = new EFEventStore(GetOptions()); List <IDomainEvent> events = new List <IDomainEvent>(); var aggAId = Guid.NewGuid(); var aggBId = Guid.NewGuid(); for (int i = 0; i < 100; i++) { if (i % 10 == 0) { events.Add(new EventAggA(aggAId)); } else { events.Add(new EventAggB(aggBId)); } } await store.StoreDomainEventRangeAsync(events); var store2 = new EFEventStore(GetOptions()); (await store2.GetAllEventsByEventType <EventAggA>().ToListAsync()).Should().HaveCount(10); (await store2.GetAllEventsByEventType <EventAggB>().ToListAsync()).Should().HaveCount(90); } finally { DeleteAll(); } }
public async Task StoreDomainEventAsync_Multiples_WithoutBuffer_Should_BeStoredInDatabase() { try { DeleteAll(); Guid aggId = Guid.NewGuid();; var store = new EFEventStore(GetOptions()); for (int i = 0; i < 20; i++) { await store.StoreDomainEventAsync(new SampleEvent(aggId, Guid.NewGuid(), DateTime.Today) { Data = "testData" + i }); } using (var ctx = GetContext()) { ctx.Set <Event>().Count(e => e.HashedAggregateId == aggId.ToJson().GetHashCode()).Should().Be(20); var evt = ctx.Set <Event>().FirstOrDefault(); evt.Should().NotBeNull(); evt.HashedAggregateId.Should().Be(aggId.ToJson(true).GetHashCode()); evt.EventTime.Should().BeSameDateAs(DateTime.Today); evt.EventData.Should().NotBeNullOrWhiteSpace(); } } finally { DeleteAll(); } }
public async Task StoreDomainEventRangeAsync_Should_Store_AllEvents_ToDb() { try { DeleteAll(); Guid aggId = Guid.NewGuid(); var store = new EFEventStore( GetOptions(new BufferInfo(new TimeSpan(0, 0, 2), new TimeSpan(0, 0, 2)))); List <IDomainEvent> events = new List <IDomainEvent>(); for (int i = 0; i < 100; i++) { events.Add(new SampleEvent(aggId, Guid.NewGuid(), DateTime.Today) { Data = "testData" + i }); } await store.StoreDomainEventRangeAsync(events); using (var ctx = GetContext()) { ctx.Set <Event>().AsNoTracking().Count(e => e.HashedAggregateId == aggId.ToJson().GetHashCode()).Should().Be(100); var evt = ctx.Set <Event>().AsNoTracking().FirstOrDefault(); evt.Should().NotBeNull(); evt.HashedAggregateId.Should().Be(aggId.ToJson(true).GetHashCode()); evt.EventTime.Should().BeSameDateAs(DateTime.Today); evt.EventData.Should().NotBeNullOrWhiteSpace(); await ctx.Set <Event>().AsNoTracking().AllAsync(e => e.EventData.Contains("testData" + (e.Sequence - 1))); } } finally { DeleteAll(); } }
public async Task SnapshotBehavior_Generic_StoreDomainEventAsync_NoSnapshotBehaviorDefined() { try { DeleteAll(); Guid aggId = Guid.NewGuid(); var store = new EFEventStore(GetOptions()); for (int i = 0; i < 11; i++) { await store.StoreDomainEventAsync(new AggregateSnapshotEvent(aggId)); } using (var ctx = GetContext()) { ctx.Set <Event>().Count().Should().Be(11); ctx.Set <Snapshot>().Count().Should().Be(0); var agg = await new EFEventStore(GetOptions()).GetRehydratedAggregateAsync <AggregateSnapshot>(aggId); agg.Should().NotBeNull(); agg.AggIncValue.Should().Be(11); } } finally { DeleteAll(); } }
public async Task NonAggregateEvent_Should_Be_Persisted_If_User_Configure_It() { try { DeleteAll(); var store = new EFEventStore(GetOptions(shouldPersisteNonAggregateEvt: true)); await store.StoreDomainEventAsync(new NonAggEvent()); using (var ctx = GetContext()) { ctx.Set <Event>().AsNoTracking().Count().Should().Be(1); var evt = await ctx.Set <Event>().AsNoTracking().FirstOrDefaultAsync(); evt.Should().NotBeNull(); evt.AggregateIdType.Should().BeNullOrWhiteSpace(); evt.AggregateType.Should().BeNullOrWhiteSpace(); evt.HashedAggregateId.Should().NotHaveValue(); evt.SerializedAggregateId.Should().BeNullOrWhiteSpace(); } } finally { DeleteAll(); } }
public async Task SnapshotBehavior_Generic_Should_RemoveEvent_If_DeleteOptions_IsChoosen() { int i = 0; _snapshotProviderMock.Setup(m => m.GetBehaviorForEventType(typeof(AggregateSnapshotEvent))).Returns(new NumericSnapshotBehavior(10)); try { DeleteAll(); Guid aggId = Guid.NewGuid(); var store = new EFEventStore(GetOptions(behavior: SnapshotEventsArchiveBehavior.Delete)); var events = new List <IDomainEvent>(); for (i = 0; i < 11; i++) { await store.StoreDomainEventAsync(new AggregateSnapshotEvent(aggId)); } using (var ctx = GetContext()) { ctx.Set <Event>().Count().Should().Be(1); var evt = ctx.Set <Event>().FirstOrDefault(); evt.Should().NotBeNull(); evt.HashedAggregateId.Should().Be(aggId.ToJson(true).GetHashCode()); evt.Sequence.Should().Be(11); evt.EventData.Should().NotBeNullOrWhiteSpace(); } } finally { DeleteAll(); } }
public async Task RehydrateAggregate_WithSnapshot() { var store = new EFEventStore( GetConfig(new BasicSnapshotBehaviorProvider( new Dictionary <Type, ISnapshotBehavior>() { { typeof(TestEvent), new NumericSnapshotBehavior(10) } }))); var agg = await store.GetRehydratedAggregateAsync <TestAggregate>(AggregateId); }
private void StoreNDomainEvents(ISnapshotBehaviorProvider provider = null) { var store = new EFEventStore(GetConfig(provider)); for (int i = 0; i < 1000; i++) { store.StoreDomainEventAsync(new TestEvent(Guid.NewGuid(), AggregateId) { AggregateStringValue = "test", AggregateIntValue = i }).GetAwaiter().GetResult(); } }
public async Task SnapshotBehavior_Generic_StoreDomainEventAsync_CreateSnapshot_Multiple_Same_Aggregates() { _snapshotProviderMock.Setup(m => m.GetBehaviorForEventType(typeof(AggregateSnapshotEvent))) .Returns(new NumericSnapshotBehavior(10)); try { DeleteAll(); Guid aggId = Guid.NewGuid(); var store = new EFEventStore(GetOptions(behavior: SnapshotEventsArchiveBehavior.Delete)); for (int i = 0; i < 11; i++) { await store.StoreDomainEventAsync(new AggregateSnapshotEvent(aggId)); } var otherId = Guid.NewGuid(); for (int i = 0; i < 30; i++) { if (i % 10 == 0) { otherId = Guid.NewGuid(); } await store.StoreDomainEventAsync(new AggregateSnapshotEvent(otherId)); } using (var ctx = GetContext()) { ctx.Set <Event>().Count(e => e.HashedAggregateId == aggId.ToJson(true).GetHashCode()).Should().Be(1); var evt = ctx.Set <Event>().ToList().Where(e => e.HashedAggregateId == aggId.ToJson(true).GetHashCode()).FirstOrDefault(); evt.Should().NotBeNull(); evt.HashedAggregateId.Should().Be(aggId.ToJson(true).GetHashCode()); evt.Sequence.Should().Be(11); evt.EventData.Should().NotBeNullOrWhiteSpace(); ctx.Set <Snapshot>().Count().Should().Be(1); var snap = ctx.Set <Snapshot>().FirstOrDefault(); snap.Should().NotBeNull(); evt.HashedAggregateId.Should().Be(aggId.ToJson(true).GetHashCode()); snap.AggregateType.Should().Be(typeof(AggregateSnapshot).AssemblyQualifiedName); var agg = await new EFEventStore(GetOptions()).GetRehydratedAggregateAsync <AggregateSnapshot>(aggId); agg.Should().NotBeNull(); agg.AggIncValue.Should().Be(11); } } finally { DeleteAll(); } }
public async Task StoreRangeDomainEvent(int numberEvents, bool useBuffer) { var store = new EFEventStore(GetConfig( bufferInfo: useBuffer ? BufferInfo.Default : BufferInfo.Disabled )); for (int i = 0; i < numberEvents; i++) { await store.StoreDomainEventAsync( new TestEvent(Guid.NewGuid(), AggregateId) { AggregateIntValue = 1, AggregateStringValue = "test" }); } }
public async Task Sequence_Should_Consider_AggregateId_And_AggregateType() { try { DeleteAll(); var eventStore = new EFEventStore(GetOptions()); Guid aggId = Guid.NewGuid(); var evt1Id = Guid.NewGuid(); var evt2Id = Guid.NewGuid(); await eventStore.StoreDomainEventAsync(new SampleEvent(aggId, evt1Id, DateTime.Today) { Data = "testData" }); await eventStore.StoreDomainEventAsync(new SampleAggEvent(aggId, evt2Id, DateTime.Today) { Data = "testData" }); using (var ctx = GetContext()) { ctx.Set <Event>().Count(e => e.HashedAggregateId == aggId.ToJson().GetHashCode()).Should().Be(2); var evt = ctx.Set <Event>().First(e => e.AggregateType == typeof(AggA).AssemblyQualifiedName); evt.Should().NotBeNull(); evt.HashedAggregateId.Should().Be(aggId.ToJson(true).GetHashCode()); evt.Id.Should().Be(evt1Id); evt.EventTime.Should().BeSameDateAs(DateTime.Today); evt.Sequence.Should().Be(1); evt.EventData.Should().NotBeNullOrWhiteSpace(); evt = ctx.Set <Event>().First(e => e.AggregateType == typeof(SampleAgg).AssemblyQualifiedName); evt.Should().NotBeNull(); evt.HashedAggregateId.Should().Be(aggId.ToJson(true).GetHashCode()); evt.Id.Should().Be(evt2Id); evt.EventTime.Should().BeSameDateAs(DateTime.Today); evt.Sequence.Should().Be(1); evt.EventData.Should().NotBeNullOrWhiteSpace(); } } finally { DeleteAll(); } }
public async Task GetEventStreamFromAsync_WithValidArgs_DoesNotThrowException() { // Arrange var options = new DbContextOptionsBuilder <EventStoreDbContext>() .UseSqlServer(@"Data Source=(localdb)\MSSQLLocalDB;Initial Catalog=EventStreamReadersIntegrationTests;Integrated Security=False") .Options; EventStoreDbContext context = new EventStoreDbContext(options); IEventStore eventStore = new EFEventStore(context, null); IEventStreamReader client = new InProcessEventStreamReader(eventStore); int expectedNumberOfRevisions = 7; // Act EventStream stream = await client.GetEventStreamFromAsync("19e2a7fc-d0eb-44b9-8348-e7678ccd37bc", -1, 10); // Assert Assert.Equal <int>(expectedNumberOfRevisions, stream.Revisions.Count); context.Dispose(); }
public async Task Snapshot_Behavior_Specific_Should_Respect_Rules() { _snapshotProviderMock.Setup(m => m.GetBehaviorForEventType(typeof(ThirdEvent))) .Returns(new SpecificSnapshotBehavior()); try { DeleteAll(); Guid aggId = Guid.NewGuid(); var store = new EFEventStore(GetOptions(behavior: SnapshotEventsArchiveBehavior.Delete)); await store.StoreDomainEventRangeAsync(new IDomainEvent[] { new FirstEvent(aggId), new SecondEvent(aggId), new ThirdEvent(aggId), }); using (var ctx = GetContext()) { ctx.Set <Event>().Count().Should().Be(1); var evt = ctx.Set <Event>().FirstOrDefault(); evt.Should().NotBeNull(); evt.HashedAggregateId.Should().Be(aggId.ToJson(true).GetHashCode()); evt.Sequence.Should().Be(3); evt.EventData.Should().NotBeNullOrWhiteSpace(); evt.EventType.Should().Be(typeof(ThirdEvent).AssemblyQualifiedName); ctx.Set <Snapshot>().Count().Should().Be(1); var snap = ctx.Set <Snapshot>().FirstOrDefault(); snap.Should().NotBeNull(); evt.HashedAggregateId.Should().Be(aggId.ToJson(true).GetHashCode()); snap.AggregateType.Should().Be(typeof(BusinessAggregate).AssemblyQualifiedName); var agg = await new EFEventStore(GetOptions()).GetRehydratedAggregateAsync <BusinessAggregate>(aggId); agg.Should().NotBeNull(); agg.CurrentState.Should().Be(3); } } finally { DeleteAll(); } }
public async Task NonAggregateEvent_Shouldnt_Be_Persisted_If_User_Configure_It() { try { DeleteAll(); var store = new EFEventStore(GetOptions(shouldPersisteNonAggregateEvt: false)); await store.StoreDomainEventAsync(new NonAggEvent()); using (var ctx = GetContext()) { ctx.Set <Event>().AsNoTracking().Count().Should().Be(0); } } finally { DeleteAll(); } }
public async Task StoreRangeDomainEvent_Snapshot(int numberEvents, bool useBuffer) { var store = new EFEventStore( GetConfig( new BasicSnapshotBehaviorProvider(new Dictionary <Type, ISnapshotBehavior>() { { typeof(TestEvent), new NumericSnapshotBehavior(10) } }), bufferInfo: useBuffer?BufferInfo.Default: BufferInfo.Disabled)); for (int i = 0; i < numberEvents; i++) { await store.StoreDomainEventAsync( new TestEvent(Guid.NewGuid(), AggregateId) { AggregateIntValue = 1, AggregateStringValue = "test" }); } }
static void Main(string[] args) { AppInitializer.Initialize(); var options = new DbContextOptionsBuilder <EventStoreDbContext>() .UseSqlServer(@"Data Source=(localdb)\MSSQLLocalDB;Initial Catalog=EventStreamReaderExample;Integrated Security=False") .Options; var dbContext = new EventStoreDbContext(options); IEventStore eventStore = new EFEventStore(dbContext, null); IEventStreamReader eventStreamReader = new InProcessEventStreamReader(eventStore); Console.WriteLine("CATCH UP EVENT STREAM"); Task <EventStream> task = null; int initialRevision = 0; int batchSize = 1; do { task = eventStreamReader.GetEventStreamFromAsync("19e2a7fc-d0eb-44b9-8348-e7678ccd37bc", initialRevision, batchSize); initialRevision += batchSize; task.Wait(); foreach (var revision in task.Result.Revisions) { Console.WriteLine("Aggregate: " + revision.AggregateType + " - Revision: " + revision.RevisionId); } } while (task.Result != null && task.Result.Revisions.Count > 0); Console.WriteLine("Completed (up to date)"); Console.WriteLine(); Console.WriteLine("Press ENTER to continue..."); Console.ReadLine(); Console.WriteLine(); }
static void Main(string[] args) { Task t = null; CancellationTokenSource ct = null; AppInitializer.Initialize(); var options = new DbContextOptionsBuilder <EventStoreDbContext>() .UseSqlServer(@"Data Source=(localdb)\MSSQLLocalDB;Initial Catalog=EventStreamedTrackedReactiveReaderExample;Integrated Security=False") .Options; var dbContext = new EventStoreDbContext(options); IEventStore eventStore = new EFEventStore(dbContext, null); IEventStreamReader eventStreamReader = new InProcessEventStreamReader(eventStore); var eventStreamTrackingDbContext = new EventStreamTrackerDbContext( new DbContextOptionsBuilder <EventStreamTrackerDbContext>() .UseSqlServer(@"Data Source=(localdb)\MSSQLLocalDB;Initial Catalog=EventStreamedTrackedReactiveReaderExampleTrackingDb;Integrated Security=False") .Options ); IEventStreamTrackerRepository trackerRepository = new EFEventStreamTrackerRepository(eventStreamTrackingDbContext); IEventStreamTrackedReactiveReader eventStreamTrackedReader = new EventStreamTrackedReactiveReader(trackerRepository, eventStreamReader); Console.WriteLine(); Console.WriteLine("CATCHING UP ALL EVENT STREAMS (WITH PERSISTENT TRACKING AND SYNCHRONOUS HANDLER)"); try { t = eventStreamTrackedReader.CatchUpAllEventStreamsAsync("projection01", revision => { Console.WriteLine(string.Format("--> Processed revision: {0}", revision.ToString())); }); t.Wait(); } catch (AggregateException e) { Console.WriteLine(string.Format("ERROR: {0}", e.InnerException.Message)); } Console.WriteLine(); Console.WriteLine("Press <ENTER> to continue..."); Console.ReadLine(); Console.WriteLine(); Console.WriteLine(); Console.WriteLine("CONTINUOUSLY CATCHING UP ALL EVENT STREAMS (WITH PERSISTENT TRACKING AND SYNCHRONOUS HANDLER)"); ct = new CancellationTokenSource(TimeSpan.FromSeconds(30)); try { t = eventStreamTrackedReader.ContinuouslyCatchUpAllEventStreamsAsync("projection02", revision => { Console.WriteLine(string.Format("--> Processed revision: {0}", revision.ToString())); }, ct.Token); t.Wait(); } catch (AggregateException e) { Console.WriteLine(string.Format("ERROR: {0}", e.InnerException.Message)); } Console.WriteLine(); Console.WriteLine("CATCHING UP ALL EVENT STREAMS (WITH PERSISTENT TRACKING AND ASYNCHRONOUS HANDLER)"); try { t = eventStreamTrackedReader.CatchUpAllEventStreamsAsync("projection03", async revision => { Console.WriteLine(string.Format("--> Processed revision: {0}", revision.ToString())); await Task.FromResult(true); }); t.Wait(); } catch (AggregateException e) { Console.WriteLine(string.Format("ERROR: {0}", e.InnerException.Message)); } Console.WriteLine(); Console.WriteLine("Press <ENTER> to continue..."); Console.ReadLine(); Console.WriteLine(); Console.WriteLine(); Console.WriteLine("CONTINUOUSLY CATCHING UP ALL EVENT STREAMS (WITH PERSISTENT TRACKING AND ASYNCHRONOUS HANDLER)"); ct = new CancellationTokenSource(TimeSpan.FromSeconds(10)); try { t = eventStreamTrackedReader.ContinuouslyCatchUpAllEventStreamsAsync("projection04", async revision => { Console.WriteLine(string.Format("--> Processed revision: {0}", revision.ToString())); await Task.FromResult(true); }, ct.Token); t.Wait(); } catch (AggregateException e) { Console.WriteLine(string.Format("ERROR: {0}", e.InnerException.Message)); } // Dispose resources dbContext.Dispose(); eventStreamTrackingDbContext.Dispose(); Console.WriteLine(); Console.WriteLine("Press <ENTER> to exit..."); Console.ReadLine(); }
static void Main(string[] args) { Task t = null; CancellationTokenSource ct = null; AppInitializer.Initialize(); var options = new DbContextOptionsBuilder <EventStoreDbContext>() .UseSqlServer(@"Data Source=(localdb)\MSSQLLocalDB;Initial Catalog=EventStreamReactiveObservablesExample;Integrated Security=False") .Options; var dbContext = new EventStoreDbContext(options); IEventStore eventStore = new EFEventStore(dbContext, null); IEventStreamReader eventStreamReader = new InProcessEventStreamReader(eventStore); Console.WriteLine("CATCHING UP EVENT STREAM"); t = EventStoreObservables.EventStreamFrom(eventStreamReader, EventStreamCheckpoint.CreateStreamCheckpoint("19e2a7fc-d0eb-44b9-8348-e7678ccd37bc", 0, 0)) .ForEachAsync(revision => Console.WriteLine("--> Aggregate: " + revision.AggregateType + " - Revision: " + revision.RevisionId)); t.Wait(); Console.WriteLine("Completed (up to date)"); Console.WriteLine(); Console.WriteLine("Press <ENTER> to continue..."); Console.ReadLine(); Console.WriteLine(); Console.WriteLine("CONTINUOUSLY CATCHING UP EVENT STREAM"); ct = new CancellationTokenSource(TimeSpan.FromSeconds(10)); try { t = EventStoreObservables.ContinuousEventStreamFrom(eventStreamReader, EventStreamCheckpoint.CreateStreamCheckpoint("19e2a7fc-d0eb-44b9-8348-e7678ccd37bc", 0, 0)) .ForEachAsync(revision => Console.WriteLine("--> Aggregate: " + revision.AggregateType + " - Revision: " + revision.RevisionId), ct.Token); t.Wait(); } catch (AggregateException e) { if (e.InnerException is TaskCanceledException) { Console.WriteLine("ERROR: The operation has been canceled => " + e.InnerException.Message); } else { throw e; } } Console.WriteLine(); Console.WriteLine("Press <ENTER> to continue..."); Console.ReadLine(); Console.WriteLine(); Console.WriteLine("CATCHING UP ALL EVENT STREAMS"); t = EventStoreObservables.AllEventStreamsFrom(eventStreamReader, GlobalCheckpoint.Create(27)) .ForEachAsync(revision => Console.WriteLine("--> Aggregate: " + revision.AggregateType + " - Revision: " + revision.RevisionId)); t.Wait(); Console.WriteLine("Completed (up to date)"); Console.WriteLine(); Console.WriteLine("Press <ENTER> to continue..."); Console.ReadLine(); Console.WriteLine(); Console.WriteLine("CONTINUOUSLY CATCHING UP ALL EVENT STREAMS"); ct = new CancellationTokenSource(TimeSpan.FromSeconds(10)); try { t = EventStoreObservables.ContinuousAllEventStreamsFrom(eventStreamReader, GlobalCheckpoint.Create(1)) .ForEachAsync(revision => Console.WriteLine("--> Aggregate: " + revision.AggregateType + " - Revision: " + revision.RevisionId), ct.Token); t.Wait(); } catch (AggregateException e) { if (e.InnerException is TaskCanceledException) { Console.WriteLine("ERROR: The operation has been canceled => " + e.Message); } else { throw e; } } // Dispose resources dbContext.Dispose(); Console.WriteLine(); Console.WriteLine("Press <ENTER> to exit..."); Console.ReadLine(); }
public async Task RehydrateAggregate() { var store = new EFEventStore(GetConfig()); var agg = await store.GetRehydratedAggregateAsync <TestAggregate>(AggregateId); }
static void Main(string[] args) { Task t = null; CancellationTokenSource ct = null; AppInitializer.Initialize(); var options = new DbContextOptionsBuilder <EventStoreDbContext>() .UseSqlServer(@"Data Source=(localdb)\MSSQLLocalDB;Initial Catalog=EventStreamReactiveReaderExample;Integrated Security=False") .Options; var dbContext = new EventStoreDbContext(options); IEventStore eventStore = new EFEventStore(dbContext, null); IEventStreamReader eventStreamReader = new InProcessEventStreamReader(eventStore); IEventStreamReactiveReader reactiveReader = new EventStreamReactiveReader(eventStreamReader); Console.WriteLine("******** REACTIVE READER EXAMPLES ********"); Console.WriteLine(); Console.WriteLine("CATCHING UP ALL EVENT STREAMS"); try { t = reactiveReader.CatchUpAllEventStreamsAsync(GlobalCheckpoint.CreateFromStart(), revision => { Console.WriteLine(string.Format("--> Processed revision: {0}", revision.ToString())); }); t.Wait(); } catch (AggregateException e) { Console.WriteLine(string.Format("ERROR: {0}", e.InnerException.Message)); } Console.WriteLine(); Console.WriteLine("Press ENTER to continue..."); Console.ReadLine(); Console.WriteLine(); Console.WriteLine(); Console.WriteLine("CONTINUOUSLY CATCHING UP ALL EVENT STREAMS"); ct = new CancellationTokenSource(TimeSpan.FromSeconds(30)); try { t = reactiveReader.ContinuouslyCatchUpAllEventStreamsAsync(GlobalCheckpoint.CreateFromStart(), revision => { Console.WriteLine(string.Format("--> Processed revision: {0}", revision.ToString())); }, ct.Token); t.Wait(); } catch (AggregateException e) { Console.WriteLine(string.Format("ERROR: {0}", e.InnerException.Message)); } Console.WriteLine(); Console.WriteLine("Press ENTER to continue..."); Console.ReadLine(); Console.WriteLine("CATCHING UP ALL EVENT STREAMS (WITH ASYNCHRONOUS HANDLER)"); try { t = reactiveReader.CatchUpAllEventStreamsAsync(GlobalCheckpoint.CreateFromStart(), async revision => { Console.WriteLine(string.Format("--> Processed revision: {0}", revision.ToString())); await Task.FromResult(true); }); t.Wait(); } catch (AggregateException e) { Console.WriteLine(string.Format("ERROR: {0}", e.InnerException.Message)); } Console.WriteLine(); Console.WriteLine("Press ENTER to continue..."); Console.ReadLine(); Console.WriteLine(); Console.WriteLine(); Console.WriteLine("CONTINUOUSLY CATCHING UP ALL EVENT STREAMS (WITH ASYNCHRONOUS HANDLER)"); ct = new CancellationTokenSource(TimeSpan.FromSeconds(10)); try { t = reactiveReader.ContinuouslyCatchUpAllEventStreamsAsync(GlobalCheckpoint.CreateFromStart(), async revision => { Console.WriteLine(string.Format("--> Processed revision: {0}", revision.ToString())); await Task.FromResult(true); }, ct.Token); t.Wait(); } catch (AggregateException e) { Console.WriteLine(string.Format("ERROR: {0}", e.InnerException.Message)); } // Dispose resources dbContext.Dispose(); Console.WriteLine(); Console.WriteLine("Press ENTER to exit..."); Console.ReadLine(); }