Ejemplo n.º 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();
        }
Ejemplo n.º 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();
        }