Beispiel #1
0
        private static void ApplyEventsToSaga(IEventStream stream, ISaga saga)
        {
            foreach (var @event in stream.CommittedEvents.Select(x => x.Body))
            {
                saga.Transition(@event);
            }

            saga.ClearUncommittedEvents();
            saga.ClearUndispatchedMessages();
        }
Beispiel #2
0
        public void Save(string bucketId, ISaga saga, Guid commitId, Action <IDictionary <string, object> > updateHeaders)
        {
            if (saga == null)
            {
                throw new ArgumentNullException("saga", ExceptionMessages.NullArgument);
            }

            Dictionary <string, object> headers = PrepareHeaders(saga, updateHeaders);
            IEventStream stream = this.PrepareStream(bucketId, saga, headers);

            Persist(stream, commitId);

            saga.ClearUncommittedEvents();
            saga.ClearUndispatchedMessages();
        }