Пример #1
0
        /// <summary>Parameterized constructor.
        /// </summary>
        /// <param name="processingCommandCache"></param>
        /// <param name="commandAsyncResultManager"></param>
        /// <param name="commandHandlerProvider"></param>
        /// <param name="aggregateRootTypeProvider"></param>
        /// <param name="eventSender"></param>
        /// <param name="retryService"></param>
        /// <param name="commandContext"></param>
        /// <param name="loggerFactory"></param>
        /// <exception cref="Exception"></exception>
        public DefaultCommandExecutor(
            IProcessingCommandCache processingCommandCache,
            ICommandAsyncResultManager commandAsyncResultManager,
            ICommandHandlerProvider commandHandlerProvider,
            IAggregateRootTypeProvider aggregateRootTypeProvider,
            IEventSender eventSender,
            IRetryService retryService,
            ICommandContext commandContext,
            ILoggerFactory loggerFactory)
        {
            _processingCommandCache    = processingCommandCache;
            _commandAsyncResultManager = commandAsyncResultManager;
            _commandHandlerProvider    = commandHandlerProvider;
            _aggregateRootTypeProvider = aggregateRootTypeProvider;
            _eventSender     = eventSender;
            _retryService    = retryService;
            _commandContext  = commandContext;
            _trackingContext = commandContext as ITrackingContext;
            _logger          = loggerFactory.Create(GetType().Name);

            if (_trackingContext == null)
            {
                throw new Exception("Command context must also implement ITrackingContext interface.");
            }
        }
Пример #2
0
        public DefaultCommandExecutor(
            IProcessingCommandCache processingCommandCache,
            ICommandAsyncResultManager commandAsyncResultManager,
            ICommandHandlerProvider commandHandlerProvider,
            IAggregateRootTypeProvider aggregateRootTypeProvider,
            IMemoryCache memoryCache,
            IRepository repository,
            IRetryCommandService retryCommandService,
            IEventStore eventStore,
            IEventPublisher eventPublisher,
            IEventPersistenceSynchronizerProvider eventPersistenceSynchronizerProvider,
            ICommandContext commandContext,
            ILoggerFactory loggerFactory)
        {
            _processingCommandCache = processingCommandCache;
            _commandAsyncResultManager = commandAsyncResultManager;
            _commandHandlerProvider = commandHandlerProvider;
            _aggregateRootTypeProvider = aggregateRootTypeProvider;
            _memoryCache = memoryCache;
            _repository = repository;
            _retryCommandService = retryCommandService;
            _eventStore = eventStore;
            _eventPublisher = eventPublisher;
            _eventPersistenceSynchronizerProvider = eventPersistenceSynchronizerProvider;
            _commandContext = commandContext;
            _trackingContext = commandContext as ITrackingContext;
            _logger = loggerFactory.Create(GetType().Name);

            if (_trackingContext == null)
            {
                throw new Exception("command context must also implement ITrackingContext interface.");
            }
        }
Пример #3
0
        private AggregateRoot GetDirtyAggregate(ITrackingContext trackingContext)
        {
            var trackedAggregateRoots   = trackingContext.GetTrackedAggregateRoots();
            var dirtyAggregateRoots     = trackedAggregateRoots.Where(x => x.GetUncommittedEvents().Any()).ToList();
            var dirtyAggregateRootCount = dirtyAggregateRoots.Count();

            if (dirtyAggregateRootCount == 0)
            {
                return(null);
            }
            else if (dirtyAggregateRootCount > 1)
            {
                throw new Exception("Detected more than one new or modified aggregates.");
            }

            return(dirtyAggregateRoots.Single());
        }
Пример #4
0
 public DefaultCommandExecutor(
     IProcessingCommandCache processingCommandCache,
     ICommandAsyncResultManager commandAsyncResultManager,
     ICommandHandlerProvider commandHandlerProvider,
     IAggregateRootTypeProvider aggregateRootTypeProvider,
     IMemoryCacheRefreshService memoryCacheRefreshService,
     IRetryCommandService retryCommandService,
     IEventStore eventStore,
     IEventPublisher eventPublisher,
     ICommandContext commandContext,
     ILoggerFactory loggerFactory)
 {
     _processingCommandCache = processingCommandCache;
     _commandAsyncResultManager = commandAsyncResultManager;
     _commandHandlerProvider = commandHandlerProvider;
     _aggregateRootTypeProvider = aggregateRootTypeProvider;
     _memoryCacheRefreshService = memoryCacheRefreshService;
     _retryCommandService = retryCommandService;
     _eventStore = eventStore;
     _eventPublisher = eventPublisher;
     _commandContext = commandContext;
     _trackingContext = commandContext as ITrackingContext;
     _logger = loggerFactory.Create(GetType().Name);
 }
Пример #5
0
        private IAggregateRoot GetDirtyAggregate(ITrackingContext trackingContext)
        {
            var trackedAggregateRoots = trackingContext.GetTrackedAggregateRoots();
            var dirtyAggregateRoots = trackedAggregateRoots.Where(x => x.GetUncommittedEvents().Any()).ToList();
            var dirtyAggregateRootCount = dirtyAggregateRoots.Count();

            if (dirtyAggregateRootCount == 0)
            {
                return null;
            }
            if (dirtyAggregateRootCount > 1)
            {
                throw new ENodeException("Detected more than one dirty aggregates [{0}].", dirtyAggregateRootCount);
            }

            return dirtyAggregateRoots.Single();
        }
Пример #6
0
        private AggregateRoot GetDirtyAggregate(ITrackingContext trackingContext)
        {
            var trackedAggregateRoots = trackingContext.GetTrackedAggregateRoots();
            var dirtyAggregateRoots = trackedAggregateRoots.Where(x => x.GetUncommittedEvents().Count() > 0);
            var dirtyAggregateRootCount = dirtyAggregateRoots.Count();

            if (dirtyAggregateRootCount == 0)
            {
                return null;
            }
            else if (dirtyAggregateRootCount > 1)
            {
                throw new Exception("Detected more than one new or modified aggregates.");
            }

            return dirtyAggregateRoots.Single();
        }