Beispiel #1
0
        public void Initialize(bool purgeExistingViews = false)
        {
            _logger.Info("Initializing event dispatcher with view managers: {0}", string.Join(", ", _viewManagers));

            _logger.Debug("Initiating immediate full catchup");
            _work.Enqueue(PieceOfWork.FullCatchUp(purgeExistingViews));

            _logger.Debug("Starting automatic catchup timer with {0} ms interval", _automaticCatchUpTimer.Interval);
            _automaticCatchUpTimer.Start();
            _worker.Start();
        }
        public void Initialize(IEventStore eventStore, bool purgeExistingViews = false)
        {
            if (eventStore == null)
            {
                throw new ArgumentNullException("eventStore");
            }
            _logger.Info("Initializing event dispatcher with view managers: {0}", string.Join(", ", _viewManagers));

            _logger.Debug("Initiating immediate full catchup");
            _work.Enqueue(PieceOfWork.FullCatchUp(purgeExistingViews: purgeExistingViews));

            _logger.Debug("Starting automatic catchup timer with {0} ms interval", _automaticCatchUpTimer.Interval);
            _automaticCatchUpTimer.Start();
            _worker.Start();
        }
        public ViewManagerEventDispatcher(IAggregateRootRepository aggregateRootRepository, IEventStore eventStore,
                                          IDomainEventSerializer domainEventSerializer, IDomainTypeNameMapper domainTypeNameMapper, params IViewManager[] viewManagers)
        {
            if (aggregateRootRepository == null)
            {
                throw new ArgumentNullException("aggregateRootRepository");
            }
            if (eventStore == null)
            {
                throw new ArgumentNullException("eventStore");
            }
            if (domainEventSerializer == null)
            {
                throw new ArgumentNullException("domainEventSerializer");
            }
            if (domainTypeNameMapper == null)
            {
                throw new ArgumentNullException("domainTypeNameMapper");
            }
            if (viewManagers == null)
            {
                throw new ArgumentNullException("viewManagers");
            }

            _aggregateRootRepository = aggregateRootRepository;
            _eventStore            = eventStore;
            _domainEventSerializer = domainEventSerializer;
            _domainTypeNameMapper  = domainTypeNameMapper;

            viewManagers.ToList().ForEach(view => _viewManagers.Enqueue(view));

            _worker = new Thread(DoWork)
            {
                IsBackground = true
            };

            _automaticCatchUpTimer.Elapsed += delegate
            {
                _work.Enqueue(PieceOfWork.FullCatchUp(false));
            };

            AutomaticCatchUpInterval = TimeSpan.FromSeconds(1);
        }