Пример #1
0
        public async Task Deliver(ScheduledCommand scheduled)
        {
            var command = scheduled.ToScheduledCommand <TAggregate>();

            await scheduler.Deliver(command);

            scheduled.Result = command.Result;
        }
        public async Task Deliver(ScheduledCommand scheduled)
        {
            var command = scheduled.ToScheduledCommand <TAggregate>();

            //here we are setting the command.SequenceNumber to the scheduled.SequenceNumber because when
            //multiple commands are scheduled simultaniously against the same aggregate we were decrementing the
            //scheduled.SequenceNumber correctly, however we were not updating the command.SequenceNumber.
            //this is to prevent any side effects that may have been caused by that bug
            command.SequenceNumber = scheduled.SequenceNumber;

            await scheduler.Deliver(command);

            scheduled.Result = command.Result;
        }
Пример #3
0
        internal static async Task DeserializeAndDeliverScheduledCommand <TAggregate>(
            ScheduledCommand scheduled,
            ICommandScheduler <TAggregate> scheduler)
        {
            try
            {
                var command = scheduled.ToScheduledCommand <TAggregate>();
                await scheduler.Deliver(command);

                scheduled.Result = command.Result;
            }
            catch (Exception exception)
            {
                scheduled.Result = new CommandFailed(scheduled, exception);
            }
        }