public async Task CreateAccountEventIsPublishedToBus() { MassTransitDispatcher massTransitDispatcher = new MassTransitDispatcher(bus); PollingClient pollingClient = new PollingClient(store.Advanced, 100); IObserveCommits commitObserver = pollingClient.ObserveFrom(null); AccountDenormalizer denormalizer = new AccountDenormalizer(); bus.Subscribe(denormalizer); using (PollingHook pollingHook = new PollingHook(commitObserver)) { using (var subscription = commitObserver.Subscribe(massTransitDispatcher)) { commitObserver.PollNow(); commitObserver.Start(); Guid accountID = Guid.NewGuid(); string name = Guid.NewGuid().ToString(); string twitter = Guid.NewGuid().ToString(); System.Diagnostics.Debug.Print(string.Format("Creating account {0}", accountID)); client.CreateNewAccount(accountID, name, twitter); DateTime timeoutEnd = DateTime.Now.AddSeconds(10); while (denormalizer.AccountName != name && DateTime.Now < timeoutEnd) { await Task.Delay(100); } denormalizer.AccountName.Should().Be(name); } } }
public void CreateAccountEventIsPublishedToBus() { using (MassTransitDispatcher massTransitDispatcher = new MassTransitDispatcher(bus)) { PollingClient pollingClient = new PollingClient(store.Advanced, 100); IObserveCommits commitObserver = pollingClient.ObserveFrom(null); IEventHandler <SimpleAggregateCreated> denormalizer = A.Fake <IEventHandler <SimpleAggregateCreated> >(); AutoResetEvent are = new AutoResetEvent(false); A.CallTo(() => denormalizer.Handle(A <SimpleAggregateCreated> .Ignored)).Invokes(() => are.Set()); bus.Subscribe(denormalizer); using (PollingHook pollingHook = new PollingHook(commitObserver)) { using (var subscription = commitObserver.Subscribe(massTransitDispatcher)) { commitObserver.PollNow(); commitObserver.Start(); Guid aggregateID = Guid.NewGuid(); SimpleAggregate aggregate = new SimpleAggregate(aggregateID, DateTime.Now); repository.Save(aggregate, Guid.NewGuid(), (o) => { }); are.WaitOne(10000).Should().BeTrue("event should be dispatched and recieved within timeout"); } } } }
public void Init() { //checkpoint token, can be persisted so we don't need to read the EventStore from scratch string checkpointToken = null; var pollingClient = new PollingClient(Program.StoreEvents.Advanced); _observer = pollingClient.ObserveFromBucket(InvoicesBucketId, checkpointToken); _observer.Subscribe(new InvoicesObserver()); //init the projection on startup _observer.PollNow(); //start a long running task that will poll the event store periodicaly _observerTask = _observer.Start(); }
protected override void Because() { _observeCommits.PollNow(); }
public void Consume(IConsumeContext <EventStreamUpdated> message) { _commitObserver.PollNow(); }
public void Poll() { _observeCommits.PollNow(); }
protected override async Task Because() { await _observeCommits.PollNow(); }