/// <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."); } }
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."); } }
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()); }
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); }
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(); }
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(); }