Exemplo n.º 1
0
 protected override void AggregateRootEventAppliedHandler(AggregateRoot aggregateRoot, UncommittedEvent evnt)
 {
     var message = new EventMessage
                       {
                           Body = new StoredEvent
                                      {
                                          Body = evnt.Payload,
                                          CommitId = _commitId,
                                          EventId = evnt.EventIdentifier,
                                          MajorVersion = evnt.EventVersion.Major,
                                          MinorVersion = evnt.EventVersion.Minor,
                                          Sequence = evnt.EventSequence,
                                          TimeStamp = evnt.EventTimeStamp
                                      }
                       };
     IEventStream stream;
     var id = aggregateRoot.EventSourceId;
     if (!_trackedStreams.TryGetValue(id, out stream))
     {
         stream = _eventStore.CreateStream(id);
         _trackedStreams[id] = stream;
     }
     stream.Add(message);
     _eventStream.Append(evnt);
     _dirtyInstances.Add(aggregateRoot);
 }
Exemplo n.º 2
0
        public static IEnumerable<EventMessage> ToEventMessages(this IEnumerable<Envelope> events)
        {
            foreach (var evt in events)
            {
                var msg = new EventMessage { Body = evt.Body };

                //populate message headers: extra information for audit and history reasons.
                FillInEnvelopeSpecificHeaders(msg, evt);

                yield return msg;
            }
        }
Exemplo n.º 3
0
 public void Store(UncommittedEventStream eventStream)
 {
     using (var stream = _store.OpenStream(eventStream.SourceId, 0, int.MaxValue))
     {
         foreach (var uncommittedEvent in eventStream)
         {
             var eventMessage = new EventMessage{ Body = uncommittedEvent.Payload };
             eventMessage.Headers["commitId"] = eventStream.CommitId;
             stream.Add(eventMessage);
         }
         //stream.CommitChanges(Guid.NewGuid());
         stream.CommitChanges(eventStream.CommitId);
     }
 }
Exemplo n.º 4
0
 public virtual void Add(EventMessage uncommittedEvent)
 {
     if (uncommittedEvent != null && uncommittedEvent.Body != null)
         this.events.Add(uncommittedEvent);
 }
Exemplo n.º 5
0
 private static void FillInEnvelopeSpecificHeaders(EventMessage msg, Envelope evt)
 {
     foreach (var header in evt.Headers)
         msg.Headers[header.Key] = header.Value;
 }
        public virtual void Add(EventMessage uncommittedEvent)
        {
            if (uncommittedEvent == null || uncommittedEvent.Body == null)
                return;

            Logger.Debug(Resources.AppendingUncommittedToStream, this.StreamId);
            this.events.Add(uncommittedEvent);
        }
 private bool loadIfPossible(ListState currentState, EventMessage @event)
 {
     return loadIfPossible(currentState, @event.Body);
 }
Exemplo n.º 8
0
 private Event ToSimpleCQRSEvent(EventMessage msg)
 {
     return (Event) msg.Body;
 }
Exemplo n.º 9
0
 public void Add(EventMessage uncommittedEvent)
 {
     committedEvents.Add(uncommittedEvent);
     StreamRevision++;
 }
Exemplo n.º 10
0
 private CommittedEvent ToCommittedEvent(EventMessage eventMessage)
 {
     var e = (SourcedEvent)eventMessage.Body;
     return new CommittedEvent((Guid) eventMessage.Headers["commitId"], e.EventIdentifier, e.EventSourceId, e.EventSequence, e.EventTimeStamp, e, e.EventVersion);
 }