Beispiel #1
0
        /// <summary>
        /// Creates a new instance of <see cref="EventEnvelope"/> for the specified <paramref name="aggregateId"/>, <paramref name="version"/> and <paramref name="e"/>.
        /// </summary>
        /// <param name="correlationId"> The message correlation identifier that is assocaited with this <see cref="EventEnvelope"/>.</param>
        /// <param name="aggregateId">The unique <see cref="Aggregate"/> identifier that is the source of the associated <see cref="Event"/>.</param>
        /// <param name="version"> The aggregate version and associated event index that is the source of the associated <see cref="Event"/>.</param>
        /// <param name="e">The event payload that originated from the specified <see cref="Aggregate"/>.</param>
        public EventEnvelope(Guid correlationId, Guid aggregateId, EventVersion version, Event e)
        {
            Verify.NotNull(e, nameof(e));

            this.correlationId = correlationId;
            this.aggregateId   = aggregateId;
            this.version       = version;
            this.e             = e;
        }
Beispiel #2
0
        /// <summary>
        /// Dispatch all events within the specified <paramref name="commit"/>.
        /// </summary>
        /// <param name="commit">The commit instance to be dispatched.</param>
        private void DispatchCommit(Commit commit)
        {
            var commitId = commit.Id.GetValueOrDefault();
            var events   = commit.Events;

            for (var i = 0; i < events.Count; i++)
            {
                var e       = events[i];
                var version = new EventVersion(commit.Version, events.Count, i + 1);

                eventPublisher.Publish(commit.Headers, new EventEnvelope(commit.CorrelationId, commit.StreamId, version, e));
            }

            if (markDispatched)
            {
                eventStore.MarkDispatched(commitId);
            }
        }