private IEvent ConvertEventMessageToEvent(EventMessage eventMessage) { var type = eventMessage.Headers["Type"] as string; var destinationType = _typeResolver.GetType(type); return _mapper.Map(destinationType, typeof(EventMessage), eventMessage) as IEvent; }
public void Handle(EventMessage @event) { var databaseBroadcasterFor = this.databaseBroadcaster.FirstOrDefault(_ => _.ForType == @event.Body.GetType()); if (databaseBroadcasterFor == null) return; var context = new FeatureBeeContext(); databaseBroadcasterFor.Broadcast(context, @event); context.SaveChanges(); }
public virtual void Add(EventMessage uncommittedEvent) { if (uncommittedEvent == null || uncommittedEvent.Body == null) { return; } Logger.Debug(Resources.AppendingUncommittedToStream, StreamId); _events.Add(uncommittedEvent); }
public void Add_Called_ExpectCallIsProxiedToEventStream() { var eventStream = MockEventStream(); using (var stream = new NEventStoreSessionStream(DummyEventStreamsInSession(), eventStream)) { var uncommittedEvent = new EventMessage(); stream.Add(uncommittedEvent); eventStream.Received(1).Add(uncommittedEvent); } }
public void Handle(EventMessage @event) { var hubBroadcasterFor = this.hubBroadcaster.FirstOrDefault(_ => _.ForType == @event.Body.GetType()); if (hubBroadcasterFor != null) { hubBroadcasterFor.Broadcast(@event.Body); } else { Debug.WriteLine("No broadcaster found for event {0}", @event.GetType()); } }
public void Handle(EventMessage @event) { var context = new FeatureBeeContext(); var databaseBroadcasterFor = this.databaseBroadcaster.FirstOrDefault(_ => _.ForType == @event.Body.GetType()); if (databaseBroadcasterFor != null) { databaseBroadcasterFor.Broadcast(context, @event.Body); } else { Debug.WriteLine("No broadcaster found for event {0}", @event.GetType()); } context.SaveChanges(); }
public void SaveEvents(IEnumerable<DomainEvent> newEvents, Guid commitId) { lock (typeof(NEventStore)) { foreach (var @event in newEvents) { var eventMessage = new EventMessage { //Headers = new Dictionary<string, object> { { "Commit Id", commitId } }, Body = @event }; _eventStream.Add(eventMessage); } _eventStream.CommitChanges(commitId); } foreach (var @event in newEvents) { _serviceBus.Send(@event); } }
public void Add(EventMessage uncommittedEvent) { this.eventStream.Add(uncommittedEvent); }
protected void CreateTestStream(int numberOfStreams = 10) { for (var i = 0; i < numberOfStreams; i++) { using (var stream = _store.OpenStream(Guid.NewGuid(), 0, int.MaxValue)) { var eventMessage = new EventMessage { Body = "body", }; eventMessage.Headers.Add("key", "value"); stream.Add(eventMessage); stream.UncommittedHeaders.Add("header", "value"); stream.CommitChanges(Guid.NewGuid()); } } }
private static object DummyEventConverter(EventMessage eventMessage) { return new object(); }
private static Converter<EventMessage, object> StubEventConverter(EventMessage persistedEvent, object domainEvent) { var converter = Substitute.For<Converter<EventMessage, object>>(); converter(persistedEvent).Returns(domainEvent); return converter; }