public void Setup()
 {
     _consumer = new TestHandler<Message>();
     _bus = new InMemoryBus("temp");
     _bus.Subscribe(_consumer);
     ICheckpoint writerCheckpoint = new InMemoryCheckpoint(1000);
     var ioDispatcher = new IODispatcher(_bus, new PublishEnvelope(_bus));
     _readerService = new EventReaderCoreService(_bus, ioDispatcher, 10, writerCheckpoint, runHeadingReader: true);
     _subscriptionDispatcher =
         new ReaderSubscriptionDispatcher(_bus);
     _spoolProcessingResponseDispatcher = new SpooledStreamReadingDispatcher(_bus);
     _timeoutScheduler = new TimeoutScheduler();
     _workerId = Guid.NewGuid();
     _service = new ProjectionCoreService(
         _workerId, _bus, _bus, _subscriptionDispatcher, new RealTimeProvider(), ioDispatcher,
         _spoolProcessingResponseDispatcher, _timeoutScheduler);
     _bus.Subscribe(_subscriptionDispatcher.CreateSubscriber<EventReaderSubscriptionMessage.CheckpointSuggested>());
     _bus.Subscribe(_subscriptionDispatcher.CreateSubscriber<EventReaderSubscriptionMessage.CommittedEventReceived>());
     _bus.Subscribe(_subscriptionDispatcher.CreateSubscriber<EventReaderSubscriptionMessage.EofReached>());
     _bus.Subscribe(_subscriptionDispatcher.CreateSubscriber<EventReaderSubscriptionMessage.PartitionEofReached>());
     _bus.Subscribe(_subscriptionDispatcher.CreateSubscriber<EventReaderSubscriptionMessage.PartitionMeasured>());
     _bus.Subscribe(_subscriptionDispatcher.CreateSubscriber<EventReaderSubscriptionMessage.PartitionDeleted>());
     _bus.Subscribe(_subscriptionDispatcher.CreateSubscriber<EventReaderSubscriptionMessage.ProgressChanged>());
     _bus.Subscribe(_subscriptionDispatcher.CreateSubscriber<EventReaderSubscriptionMessage.SubscriptionStarted>());
     _bus.Subscribe(_subscriptionDispatcher.CreateSubscriber<EventReaderSubscriptionMessage.NotAuthorized>());
     _bus.Subscribe(_subscriptionDispatcher.CreateSubscriber<EventReaderSubscriptionMessage.ReaderAssignedReader>());
     _bus.Subscribe(_spoolProcessingResponseDispatcher.CreateSubscriber<PartitionProcessingResult>());
     _readerService.Handle(new Messages.ReaderCoreServiceMessage.StartReader());
     _service.Handle(new ProjectionCoreServiceMessage.StartCore());
 }
Exemple #2
0
        public void setup()
        {
            //TODO: this became a n integration test - proper ProjectionCoreService and ProjectionManager testing is required instead
            _bus.Subscribe(_consumer);

            _manager     = new ProjectionManager(_bus, _bus, new IPublisher[] { _bus }, checkpointForStatistics: null);
            _coreService = new ProjectionCoreService(_bus, _bus, 10, new InMemoryCheckpoint(1000));
            _bus.Subscribe <ProjectionMessage.Projections.StatusReport.Stopped>(_manager);
            _bus.Subscribe <ProjectionMessage.Projections.Management.StateReport>(_manager);
            _bus.Subscribe <ProjectionMessage.Projections.Management.StatisticsReport>(_manager);
            _bus.Subscribe <ClientMessage.WriteEventsCompleted>(_manager);
            _bus.Subscribe <ClientMessage.ReadStreamEventsBackwardCompleted>(_manager);
            _bus.Subscribe <ClientMessage.WriteEventsCompleted>(_manager);

            _bus.Subscribe <ProjectionMessage.CoreService.Management.Create>(_coreService);
            _bus.Subscribe <ProjectionMessage.CoreService.Management.Dispose>(_coreService);
            _bus.Subscribe <ProjectionMessage.Projections.Management.Start>(_coreService);
            _bus.Subscribe <ProjectionMessage.Projections.Management.Stop>(_coreService);
            _bus.Subscribe <ProjectionMessage.Projections.Management.GetState>(_coreService);
            _bus.Subscribe <ProjectionMessage.Projections.Management.UpdateStatistics>(_coreService);
            _bus.Subscribe <ClientMessage.ReadStreamEventsBackwardCompleted>(_coreService);
            _bus.Subscribe <ClientMessage.WriteEventsCompleted>(_coreService);


            When();
        }
        public void setup()
        {
            //TODO: this became a n integration test - proper ProjectionCoreService and ProjectionManager testing is required instead
            _bus.Subscribe(_consumer);

            _manager = new ProjectionManager(_bus, _bus, new IPublisher[] {_bus});
            _coreService = new ProjectionCoreService(_bus, _bus, 10, new InMemoryCheckpoint(1000));
            _bus.Subscribe<CoreProjectionManagementMessage.Started>(_manager);
            _bus.Subscribe<CoreProjectionManagementMessage.Stopped>(_manager);
            _bus.Subscribe<CoreProjectionManagementMessage.Prepared>(_manager);
            _bus.Subscribe<CoreProjectionManagementMessage.Faulted>(_manager);
            _bus.Subscribe<CoreProjectionManagementMessage.StateReport>(_manager);
            _bus.Subscribe<CoreProjectionManagementMessage.StatisticsReport>(_manager);
            _bus.Subscribe<ClientMessage.WriteEventsCompleted>(_manager);
            _bus.Subscribe<ClientMessage.ReadStreamEventsBackwardCompleted>(_manager);
            _bus.Subscribe<ClientMessage.WriteEventsCompleted>(_manager);

            _bus.Subscribe<CoreProjectionManagementMessage.CreateAndPrepare>(_coreService);
            _bus.Subscribe<CoreProjectionManagementMessage.Dispose>(_coreService);
            _bus.Subscribe<CoreProjectionManagementMessage.Start>(_coreService);
            _bus.Subscribe<CoreProjectionManagementMessage.Stop>(_coreService);
            _bus.Subscribe<CoreProjectionManagementMessage.Kill>(_coreService);
            _bus.Subscribe<CoreProjectionManagementMessage.GetState>(_coreService);
            _bus.Subscribe<CoreProjectionManagementMessage.UpdateStatistics>(_coreService);
            _bus.Subscribe<ClientMessage.ReadStreamEventsBackwardCompleted>(_coreService);
            _bus.Subscribe<ClientMessage.WriteEventsCompleted>(_coreService);

            When();
        }
Exemple #4
0
        public void Setup()
        {
            _consumer = new TestHandler <Message>();
            _bus      = new InMemoryBus("temp");
            _bus.Subscribe(_consumer);
            ICheckpoint writerCheckpoint = new InMemoryCheckpoint(1000);
            var         ioDispatcher     = new IODispatcher(_bus, new PublishEnvelope(_bus));

            _readerService          = new EventReaderCoreService(_bus, ioDispatcher, 10, writerCheckpoint, runHeadingReader: true);
            _subscriptionDispatcher =
                new ReaderSubscriptionDispatcher(_bus);
            _spoolProcessingResponseDispatcher = new SpooledStreamReadingDispatcher(_bus);
            _service = new ProjectionCoreService(
                _bus, _bus, _subscriptionDispatcher, new RealTimeProvider(), ioDispatcher,
                _spoolProcessingResponseDispatcher);
            _bus.Subscribe(_subscriptionDispatcher.CreateSubscriber <EventReaderSubscriptionMessage.CheckpointSuggested>());
            _bus.Subscribe(_subscriptionDispatcher.CreateSubscriber <EventReaderSubscriptionMessage.CommittedEventReceived>());
            _bus.Subscribe(_subscriptionDispatcher.CreateSubscriber <EventReaderSubscriptionMessage.EofReached>());
            _bus.Subscribe(_subscriptionDispatcher.CreateSubscriber <EventReaderSubscriptionMessage.PartitionEofReached>());
            _bus.Subscribe(_subscriptionDispatcher.CreateSubscriber <EventReaderSubscriptionMessage.PartitionMeasured>());
            _bus.Subscribe(_subscriptionDispatcher.CreateSubscriber <EventReaderSubscriptionMessage.ProgressChanged>());
            _bus.Subscribe(_subscriptionDispatcher.CreateSubscriber <EventReaderSubscriptionMessage.SubscriptionStarted>());
            _bus.Subscribe(_subscriptionDispatcher.CreateSubscriber <EventReaderSubscriptionMessage.NotAuthorized>());
            _bus.Subscribe(_subscriptionDispatcher.CreateSubscriber <EventReaderSubscriptionMessage.ReaderAssignedReader>());
            _bus.Subscribe(_spoolProcessingResponseDispatcher.CreateSubscriber <PartitionProcessingResult>());
            _readerService.Handle(new Messages.ReaderCoreServiceMessage.StartReader());
            _service.Handle(new ProjectionCoreServiceMessage.StartCore());
        }
 public void Setup()
 {
     _consumer = new WatchingConsumer();
     _bus = new InMemoryBus("temp");
     _bus.Subscribe(_consumer);
     _service = new ProjectionCoreService(_bus, _bus, 10, new InMemoryCheckpoint(1000));
     _service.Handle(new ProjectionMessage.CoreService.Start());
 }
        public ProjectionWorkerNode(TFChunkDb db, QueuedHandler inputQueue)
        {
            Ensure.NotNull(db, "db");

            _coreOutput = new InMemoryBus("Core Output");

            _projectionCoreService = new ProjectionCoreService(CoreOutput, inputQueue, 10, db.Config.WriterCheckpoint);
        }
Exemple #7
0
 public void Setup()
 {
     _consumer = new WatchingConsumer();
     _bus      = new InMemoryBus("temp");
     _bus.Subscribe(_consumer);
     _service = new ProjectionCoreService(_bus, _bus, 10, new InMemoryCheckpoint(1000));
     _service.Handle(new ProjectionMessage.CoreService.Start());
 }
        public ProjectionWorkerNode(TFChunkDb db, QueuedHandler inputQueue)
        {
            Ensure.NotNull(db, "db");

            _coreOutput = new InMemoryBus("Core Output");

            _projectionCoreService = new ProjectionCoreService(CoreOutput, inputQueue, 10, db.Config.WriterCheckpoint);
        }
 public ProjectionProcessingStrategy CreateSlaveProjectionProcessingStrategy(
     string name, ProjectionVersion projectionVersion, ProjectionSourceDefinition sourceDefinition,
     ProjectionConfig projectionConfig, IProjectionStateHandler stateHandler, IPublisher resultsEnvelope,
     Guid masterCoreProjectionId, ProjectionCoreService projectionCoreService)
 {
     return new SlaveQueryProcessingStrategy(
         name, projectionVersion, stateHandler, projectionConfig, sourceDefinition, projectionCoreService.Logger,
         resultsEnvelope, masterCoreProjectionId, _subscriptionDispatcher);
 }
Exemple #10
0
        public ProjectionWorkerNode(
            Guid workerId,
            TFChunkDb db,
            IQueuedHandler inputQueue,
            ITimeProvider timeProvider,
            ISingletonTimeoutScheduler timeoutScheduler,
            ProjectionType runProjections,
            bool faultOutOfOrderProjections)
        {
            _runProjections = runProjections;
            Ensure.NotNull(db, "db");

            _coreOutput = new InMemoryBus("Core Output");

            IPublisher publisher = CoreOutput;

            _subscriptionDispatcher            = new ReaderSubscriptionDispatcher(publisher);
            _spoolProcessingResponseDispatcher = new SpooledStreamReadingDispatcher(publisher);

            _ioDispatcher           = new IODispatcher(publisher, new PublishEnvelope(inputQueue));
            _eventReaderCoreService = new EventReaderCoreService(
                publisher,
                _ioDispatcher,
                10,
                db.Config.WriterCheckpoint,
                runHeadingReader: runProjections >= ProjectionType.System,
                faultOutOfOrderProjections: faultOutOfOrderProjections);

            _feedReaderService = new FeedReaderService(_subscriptionDispatcher, timeProvider);
            if (runProjections >= ProjectionType.System)
            {
                _projectionCoreServiceCommandReader = new ProjectionCoreServiceCommandReader(
                    publisher,
                    _ioDispatcher,
                    workerId.ToString("N"));

                var multiStreamWriter = new MultiStreamMessageWriter(_ioDispatcher);
                _slaveProjectionResponseWriter = new SlaveProjectionResponseWriter(multiStreamWriter);

                _projectionCoreService = new ProjectionCoreService(
                    workerId,
                    inputQueue,
                    publisher,
                    _subscriptionDispatcher,
                    timeProvider,
                    _ioDispatcher,
                    _spoolProcessingResponseDispatcher,
                    timeoutScheduler);

                var responseWriter = new ResponseWriter(_ioDispatcher);
                _coreResponseWriter = new ProjectionCoreResponseWriter(responseWriter);
            }
        }
        public ProjectionWorkerNode(
            Guid workerId,
            TFChunkDb db,
            QueuedHandler inputQueue,
            ITimeProvider timeProvider,
            ISingletonTimeoutScheduler timeoutScheduler,
            ProjectionType runProjections)
        {
            _runProjections = runProjections;
            Ensure.NotNull(db, "db");

            _coreOutput = new InMemoryBus("Core Output");

            IPublisher publisher = CoreOutput;
            _subscriptionDispatcher = new ReaderSubscriptionDispatcher(publisher);
            _spoolProcessingResponseDispatcher = new SpooledStreamReadingDispatcher(publisher);

            _ioDispatcher = new IODispatcher(publisher, new PublishEnvelope(inputQueue));
            _eventReaderCoreService = new EventReaderCoreService(
                publisher,
                _ioDispatcher,
                10,
                db.Config.WriterCheckpoint,
                runHeadingReader: runProjections >= ProjectionType.System);

            _feedReaderService = new FeedReaderService(_subscriptionDispatcher, timeProvider);
            if (runProjections >= ProjectionType.System)
            {
                _projectionCoreServiceCommandReader = new ProjectionCoreServiceCommandReader(
                    publisher,
                    _ioDispatcher,
                    workerId.ToString("N"));

                var multiStreamWriter = new MultiStreamMessageWriter(_ioDispatcher);
                _slaveProjectionResponseWriter = new SlaveProjectionResponseWriter(multiStreamWriter);

                _projectionCoreService = new ProjectionCoreService(
                    workerId,
                    inputQueue,
                    publisher,
                    _subscriptionDispatcher,
                    timeProvider,
                    _ioDispatcher,
                    _spoolProcessingResponseDispatcher,
                    timeoutScheduler);

                var responseWriter = new ResponseWriter(_ioDispatcher);
                _coreResponseWriter = new ProjectionCoreResponseWriter(responseWriter);
            }
        }
        public ProjectionWorkerNode(TFChunkDb db, IPublisher coreQueue, HttpService httpService)
        {
            Ensure.NotNull(db, "db");
            Ensure.NotNull(coreQueue, "coreQueue");

            _coreQueue = coreQueue;
            CoreOutput = new InMemoryBus("Core Output");

            _projectionCoreService = new ProjectionCoreService(CoreOutput, 10, db.Config.WriterCheckpoint);
            CoreOutput.Subscribe(Forwarder.Create <Message>(_coreQueue)); // forward all

            _projectionManager = new ProjectionManager(CoreOutput, db.Config.WriterCheckpoint);

            httpService.SetupController(new ProjectionsController(_coreQueue));
        }
        public void setup()
        {
            //TODO: this became a n integration test - proper ProjectionCoreService and ProjectionManager testing is required instead
            _bus.Subscribe(_consumer);

            _manager = new ProjectionManager(_bus, _bus, new IPublisher[] {_bus});
            _coreService = new ProjectionCoreService(_bus, _bus, 10, new InMemoryCheckpoint(1000));
            _bus.Subscribe<CoreProjectionManagementMessage.Started>(_manager);
            _bus.Subscribe<CoreProjectionManagementMessage.Stopped>(_manager);
            _bus.Subscribe<CoreProjectionManagementMessage.Prepared>(_manager);
            _bus.Subscribe<CoreProjectionManagementMessage.Faulted>(_manager);
            _bus.Subscribe<CoreProjectionManagementMessage.StateReport>(_manager);
            _bus.Subscribe<CoreProjectionManagementMessage.StatisticsReport>(_manager);
            _bus.Subscribe<ClientMessage.WriteEventsCompleted>(_manager);
            _bus.Subscribe<ClientMessage.ReadStreamEventsBackwardCompleted>(_manager);
            _bus.Subscribe<ClientMessage.WriteEventsCompleted>(_manager);
            _bus.Subscribe<SystemMessage.StateChangeMessage>(_manager);

            _bus.Subscribe<CoreProjectionManagementMessage.CreateAndPrepare>(_coreService);
            _bus.Subscribe<CoreProjectionManagementMessage.CreatePrepared>(_coreService);
            _bus.Subscribe<CoreProjectionManagementMessage.Dispose>(_coreService);
            _bus.Subscribe<CoreProjectionManagementMessage.Start>(_coreService);
            _bus.Subscribe<CoreProjectionManagementMessage.LoadStopped>(_coreService);
            _bus.Subscribe<CoreProjectionManagementMessage.Stop>(_coreService);
            _bus.Subscribe<CoreProjectionManagementMessage.Kill>(_coreService);
            _bus.Subscribe<CoreProjectionManagementMessage.GetState>(_coreService);
            _bus.Subscribe<CoreProjectionManagementMessage.GetDebugState>(_coreService);
            _bus.Subscribe<CoreProjectionManagementMessage.UpdateStatistics>(_coreService);
            _bus.Subscribe<ClientMessage.ReadStreamEventsBackwardCompleted>(_coreService);
            _bus.Subscribe<ClientMessage.WriteEventsCompleted>(_coreService);
            _bus.Subscribe<ProjectionCoreServiceMessage.Start>(_coreService);
            _bus.Subscribe<ProjectionCoreServiceMessage.Stop>(_coreService);
            _bus.Subscribe<ProjectionCoreServiceMessage.Tick>(_coreService);
            _bus.Subscribe<ProjectionCoreServiceMessage.CommittedEventDistributed>(_coreService);
            _bus.Subscribe<ProjectionCoreServiceMessage.EventReaderEof>(_coreService);
            _bus.Subscribe<ProjectionCoreServiceMessage.EventReaderIdle>(_coreService);
            _bus.Subscribe<ProjectionSubscriptionManagement.Pause>(_coreService);
            _bus.Subscribe<ProjectionSubscriptionManagement.Resume>(_coreService);
            _bus.Subscribe<ProjectionSubscriptionManagement.Subscribe>(_coreService);
            _bus.Subscribe<ProjectionSubscriptionManagement.Unsubscribe>(_coreService);
            

            Given();
            When();
        }
Exemple #14
0
        public ProjectionWorkerNode(
            Guid workerId,
            TFChunkDb db,
            IQueuedHandler inputQueue,
            ITimeProvider timeProvider,
            ISingletonTimeoutScheduler timeoutScheduler,
            ProjectionType runProjections,
            bool faultOutOfOrderProjections,
            IPublisher leaderOutputBus,
            ProjectionsStandardComponents configuration)
        {
            _runProjections = runProjections;
            Ensure.NotNull(db, "db");

            _coreOutput      = new InMemoryBus("Core Output");
            _leaderOutputBus = leaderOutputBus;

            IPublisher publisher = CoreOutput;

            _subscriptionDispatcher = new ReaderSubscriptionDispatcher(publisher);

            _ioDispatcher           = new IODispatcher(publisher, new PublishEnvelope(inputQueue), true);
            _eventReaderCoreService = new EventReaderCoreService(
                publisher,
                _ioDispatcher,
                10,
                db.Config.WriterCheckpoint,
                runHeadingReader: runProjections >= ProjectionType.System,
                faultOutOfOrderProjections: faultOutOfOrderProjections);

            _feedReaderService = new FeedReaderService(_subscriptionDispatcher, timeProvider);
            if (runProjections >= ProjectionType.System)
            {
                _projectionCoreService = new ProjectionCoreService(
                    workerId,
                    inputQueue,
                    publisher,
                    _subscriptionDispatcher,
                    timeProvider,
                    _ioDispatcher,
                    timeoutScheduler,
                    configuration);
            }
        }
Exemple #15
0
        public virtual void Setup()
        {
            _consumer = new TestHandler <Message>();
            _bus      = new InMemoryBus("temp");
            _bus.Subscribe(_consumer);
            ICheckpoint writerCheckpoint = new InMemoryCheckpoint(1000);
            var         ioDispatcher     = new IODispatcher(_bus, new PublishEnvelope(_bus), true);

            _readerService = new EventReaderCoreService(_bus, ioDispatcher, 10, writerCheckpoint,
                                                        runHeadingReader: true, faultOutOfOrderProjections: true);
            _subscriptionDispatcher =
                new ReaderSubscriptionDispatcher(_bus);
            _timeoutScheduler = new TimeoutScheduler();
            _workerId         = Guid.NewGuid();
            var guardBus      = new GuardBusToTriggerFixingIfUsed();
            var configuration = new ProjectionsStandardComponents(1, ProjectionType.All, guardBus, guardBus, guardBus, true,
                                                                  500, 250);

            _service = new ProjectionCoreService(
                _workerId, _bus, _bus, _subscriptionDispatcher, new RealTimeProvider(), ioDispatcher, _timeoutScheduler, configuration);
            _bus.Subscribe(
                _subscriptionDispatcher.CreateSubscriber <EventReaderSubscriptionMessage.CheckpointSuggested>());
            _bus.Subscribe(_subscriptionDispatcher
                           .CreateSubscriber <EventReaderSubscriptionMessage.CommittedEventReceived>());
            _bus.Subscribe(_subscriptionDispatcher.CreateSubscriber <EventReaderSubscriptionMessage.EofReached>());
            _bus.Subscribe(
                _subscriptionDispatcher.CreateSubscriber <EventReaderSubscriptionMessage.PartitionEofReached>());
            _bus.Subscribe(_subscriptionDispatcher.CreateSubscriber <EventReaderSubscriptionMessage.PartitionDeleted>());
            _bus.Subscribe(_subscriptionDispatcher.CreateSubscriber <EventReaderSubscriptionMessage.ProgressChanged>());
            _bus.Subscribe(
                _subscriptionDispatcher.CreateSubscriber <EventReaderSubscriptionMessage.SubscriptionStarted>());
            _bus.Subscribe(_subscriptionDispatcher.CreateSubscriber <EventReaderSubscriptionMessage.NotAuthorized>());
            _bus.Subscribe(
                _subscriptionDispatcher.CreateSubscriber <EventReaderSubscriptionMessage.ReaderAssignedReader>());

            var instanceCorrelationId = Guid.NewGuid();

            _readerService.Handle(new ReaderCoreServiceMessage.StartReader(instanceCorrelationId));
            _service.Handle(new ProjectionCoreServiceMessage.StartCore(instanceCorrelationId));
        }
        public ProjectionWorkerNode(TFChunkDb db, QueuedHandler inputQueue, ITimeProvider timeProvider, RunProjections runProjections)
        {
            _runProjections = runProjections;
            Ensure.NotNull(db, "db");

            _coreOutput = new InMemoryBus("Core Output");

            IPublisher publisher = CoreOutput;
            _subscriptionDispatcher =
                new PublishSubscribeDispatcher
                    <ReaderSubscriptionManagement.Subscribe,
                        ReaderSubscriptionManagement.ReaderSubscriptionManagementMessage, EventReaderSubscriptionMessage
                        >(publisher, v => v.SubscriptionId, v => v.SubscriptionId);
            ;
            _eventReaderCoreService = new EventReaderCoreService(
                publisher, 10, db.Config.WriterCheckpoint, runHeadingReader: runProjections >= RunProjections.System);
            _feedReaderService = new FeedReaderService(_subscriptionDispatcher, timeProvider);
            if (runProjections >= RunProjections.System)
            {
                _projectionCoreService = new ProjectionCoreService(inputQueue, publisher, _subscriptionDispatcher, timeProvider);
            }
        }
        public void Setup()
        {
            _consumer = new TestHandler <Message>();
            _bus      = new InMemoryBus("temp");
            _bus.Subscribe(_consumer);
            ICheckpoint writerCheckpoint = new InMemoryCheckpoint(1000);

            _readerService          = new EventReaderCoreService(_bus, 10, writerCheckpoint, runHeadingReader: true);
            _subscriptionDispatcher =
                new PublishSubscribeDispatcher
                <ReaderSubscriptionManagement.Subscribe,
                 ReaderSubscriptionManagement.ReaderSubscriptionManagementMessage, EventReaderSubscriptionMessage
                >(_bus, v => v.SubscriptionId, v => v.SubscriptionId);
            _service = new ProjectionCoreService(_bus, _bus, _subscriptionDispatcher, new RealTimeProvider());
            _bus.Subscribe(_subscriptionDispatcher.CreateSubscriber <EventReaderSubscriptionMessage.CheckpointSuggested>());
            _bus.Subscribe(_subscriptionDispatcher.CreateSubscriber <EventReaderSubscriptionMessage.CommittedEventReceived>());
            _bus.Subscribe(_subscriptionDispatcher.CreateSubscriber <EventReaderSubscriptionMessage.EofReached>());
            _bus.Subscribe(_subscriptionDispatcher.CreateSubscriber <EventReaderSubscriptionMessage.ProgressChanged>());
            _bus.Subscribe(_subscriptionDispatcher.CreateSubscriber <EventReaderSubscriptionMessage.NotAuthorized>());
            _readerService.Handle(new Messages.ReaderCoreServiceMessage.StartReader());
            _service.Handle(new ProjectionCoreServiceMessage.StartCore());
        }
        public ProjectionWorkerNode(TFChunkDb db, QueuedHandler inputQueue, ITimeProvider timeProvider, RunProjections runProjections)
        {
            _runProjections = runProjections;
            Ensure.NotNull(db, "db");

            _coreOutput = new InMemoryBus("Core Output");

            IPublisher publisher = CoreOutput;
            _subscriptionDispatcher =
                new ReaderSubscriptionDispatcher(publisher);
            _spoolProcessingResponseDispatcher = new SpooledStreamReadingDispatcher(publisher);

            _ioDispatcher = new IODispatcher(publisher, new PublishEnvelope(inputQueue));
            _eventReaderCoreService = new EventReaderCoreService(
                publisher, _ioDispatcher, 10, db.Config.WriterCheckpoint, runHeadingReader: runProjections >= RunProjections.System);
            _feedReaderService = new FeedReaderService(_subscriptionDispatcher, timeProvider);
            if (runProjections >= RunProjections.System)
            {
                _projectionCoreService = new ProjectionCoreService(
                    inputQueue, publisher, _subscriptionDispatcher, timeProvider, _ioDispatcher,
                    _spoolProcessingResponseDispatcher);
            }
        }
Exemple #19
0
        public ProjectionWorkerNode(TFChunkDb db, QueuedHandler inputQueue, ITimeProvider timeProvider, RunProjections runProjections)
        {
            _runProjections = runProjections;
            Ensure.NotNull(db, "db");

            _coreOutput = new InMemoryBus("Core Output");

            IPublisher publisher = CoreOutput;

            _subscriptionDispatcher =
                new PublishSubscribeDispatcher
                <ReaderSubscriptionManagement.Subscribe,
                 ReaderSubscriptionManagement.ReaderSubscriptionManagementMessage, EventReaderSubscriptionMessage
                >(publisher, v => v.SubscriptionId, v => v.SubscriptionId);
            ;
            _eventReaderCoreService = new EventReaderCoreService(
                publisher, 10, db.Config.WriterCheckpoint, runHeadingReader: runProjections >= RunProjections.System);
            _feedReaderService = new FeedReaderService(_subscriptionDispatcher, timeProvider);
            if (runProjections >= RunProjections.System)
            {
                _projectionCoreService = new ProjectionCoreService(inputQueue, publisher, _subscriptionDispatcher, timeProvider);
            }
        }
        public ProjectionWorkerNode(TFChunkDb db, QueuedHandler inputQueue, ITimeProvider timeProvider, RunProjections runProjections)
        {
            _runProjections = runProjections;
            Ensure.NotNull(db, "db");

            _coreOutput = new InMemoryBus("Core Output");

            IPublisher publisher = CoreOutput;

            _subscriptionDispatcher =
                new ReaderSubscriptionDispatcher(publisher);
            _spoolProcessingResponseDispatcher = new SpooledStreamReadingDispatcher(publisher);

            _ioDispatcher           = new IODispatcher(publisher, new PublishEnvelope(inputQueue));
            _eventReaderCoreService = new EventReaderCoreService(
                publisher, _ioDispatcher, 10, db.Config.WriterCheckpoint, runHeadingReader: runProjections >= RunProjections.System);
            _feedReaderService = new FeedReaderService(_subscriptionDispatcher, timeProvider);
            if (runProjections >= RunProjections.System)
            {
                _projectionCoreService = new ProjectionCoreService(
                    inputQueue, publisher, _subscriptionDispatcher, timeProvider, _ioDispatcher,
                    _spoolProcessingResponseDispatcher);
            }
        }
        private void SetUpCoreServices(
            Guid workerId,
            IBus bus,
            IPublisher inputQueue,
            InMemoryBus output_,
            ISingletonTimeoutScheduler timeoutScheduler)
        {
            var output = (output_ ?? inputQueue);
            ICheckpoint writerCheckpoint = new InMemoryCheckpoint(1000);
            var readerService = new EventReaderCoreService(
                output,
                _ioDispatcher,
                10,
                writerCheckpoint,
                runHeadingReader: true);
            _subscriptionDispatcher = new ReaderSubscriptionDispatcher(inputQueue);
            var spoolProcessingResponseDispatcher = new SpooledStreamReadingDispatcher(GetInputQueue());

            bus.Subscribe(
                _subscriptionDispatcher.CreateSubscriber<EventReaderSubscriptionMessage.CheckpointSuggested>());
            bus.Subscribe(
                _subscriptionDispatcher.CreateSubscriber<EventReaderSubscriptionMessage.CommittedEventReceived>());
            bus.Subscribe(_subscriptionDispatcher.CreateSubscriber<EventReaderSubscriptionMessage.EofReached>());
            bus.Subscribe(
                _subscriptionDispatcher.CreateSubscriber<EventReaderSubscriptionMessage.PartitionEofReached>());
            bus.Subscribe(_subscriptionDispatcher.CreateSubscriber<EventReaderSubscriptionMessage.PartitionMeasured>());
            bus.Subscribe(_subscriptionDispatcher.CreateSubscriber<EventReaderSubscriptionMessage.PartitionDeleted>());
            bus.Subscribe(_subscriptionDispatcher.CreateSubscriber<EventReaderSubscriptionMessage.ProgressChanged>());
            bus.Subscribe(
                _subscriptionDispatcher.CreateSubscriber<EventReaderSubscriptionMessage.SubscriptionStarted>());
            bus.Subscribe(_subscriptionDispatcher.CreateSubscriber<EventReaderSubscriptionMessage.NotAuthorized>());
            bus.Subscribe(
                _subscriptionDispatcher.CreateSubscriber<EventReaderSubscriptionMessage.ReaderAssignedReader>());
            bus.Subscribe(spoolProcessingResponseDispatcher.CreateSubscriber<PartitionProcessingResult>());

            var ioDispatcher = new IODispatcher(output, new PublishEnvelope(inputQueue));
//            var coreServiceCommandReader = new ProjectionCoreServiceCommandReader(
//                output,
//                ioDispatcher,
//                workerId.ToString("N"));

            var coreService = new ProjectionCoreService(
                workerId,
                inputQueue,
                output,
                _subscriptionDispatcher,
                _timeProvider,
                ioDispatcher,
                spoolProcessingResponseDispatcher,
                timeoutScheduler);

            bus.Subscribe<CoreProjectionManagementMessage.CreateAndPrepare>(coreService);
            bus.Subscribe<CoreProjectionManagementMessage.CreatePrepared>(coreService);
            bus.Subscribe<CoreProjectionManagementMessage.CreateAndPrepareSlave>(coreService);
            bus.Subscribe<CoreProjectionManagementMessage.Dispose>(coreService);
            bus.Subscribe<CoreProjectionManagementMessage.Start>(coreService);
            bus.Subscribe<CoreProjectionManagementMessage.LoadStopped>(coreService);
            bus.Subscribe<CoreProjectionManagementMessage.Stop>(coreService);
            bus.Subscribe<CoreProjectionManagementMessage.Kill>(coreService);
            bus.Subscribe<CoreProjectionManagementMessage.GetState>(coreService);
            bus.Subscribe<CoreProjectionManagementMessage.GetResult>(coreService);
            bus.Subscribe<CoreProjectionProcessingMessage.CheckpointCompleted>(coreService);
            bus.Subscribe<CoreProjectionProcessingMessage.CheckpointLoaded>(coreService);
            bus.Subscribe<CoreProjectionProcessingMessage.PrerecordedEventsLoaded>(coreService);
            bus.Subscribe<CoreProjectionProcessingMessage.RestartRequested>(coreService);
            bus.Subscribe<CoreProjectionProcessingMessage.Failed>(coreService);
            bus.Subscribe<ClientMessage.ReadStreamEventsForwardCompleted>(ioDispatcher.ForwardReader);
            bus.Subscribe<ClientMessage.ReadStreamEventsBackwardCompleted>(ioDispatcher.BackwardReader);
            bus.Subscribe<ClientMessage.WriteEventsCompleted>(ioDispatcher.Writer);
            bus.Subscribe<ClientMessage.DeleteStreamCompleted>(ioDispatcher.StreamDeleter);
            bus.Subscribe<IODispatcherDelayedMessage>(ioDispatcher.Awaker);
            bus.Subscribe<IODispatcherDelayedMessage>(ioDispatcher);
            bus.Subscribe<ProjectionCoreServiceMessage.StartCore>(coreService);
            bus.Subscribe<ProjectionCoreServiceMessage.StopCore>(coreService);
            bus.Subscribe<ReaderCoreServiceMessage.StartReader>(readerService);
            bus.Subscribe<ReaderCoreServiceMessage.StopReader>(readerService);
            bus.Subscribe<ProjectionCoreServiceMessage.CoreTick>(coreService);
            bus.Subscribe<ProjectionManagementMessage.SlaveProjectionsStarted>(coreService);
            bus.Subscribe<ReaderCoreServiceMessage.ReaderTick>(readerService);
            bus.Subscribe<ReaderSubscriptionMessage.CommittedEventDistributed>(readerService);
            bus.Subscribe<ReaderSubscriptionMessage.EventReaderEof>(readerService);
            bus.Subscribe<ReaderSubscriptionMessage.EventReaderPartitionEof>(readerService);
            bus.Subscribe<ReaderSubscriptionMessage.EventReaderPartitionDeleted>(readerService);
            bus.Subscribe<ReaderSubscriptionMessage.EventReaderPartitionMeasured>(readerService);
            bus.Subscribe<ReaderSubscriptionMessage.EventReaderNotAuthorized>(readerService);
            bus.Subscribe<ReaderSubscriptionMessage.EventReaderIdle>(readerService);
            bus.Subscribe<ReaderSubscriptionMessage.EventReaderStarting>(readerService);
            bus.Subscribe<ReaderSubscriptionManagement.Pause>(readerService);
            bus.Subscribe<ReaderSubscriptionManagement.Resume>(readerService);
            bus.Subscribe<ReaderSubscriptionManagement.Subscribe>(readerService);
            bus.Subscribe<ReaderSubscriptionManagement.Unsubscribe>(readerService);
            bus.Subscribe<ReaderSubscriptionManagement.SpoolStreamReadingCore>(readerService);
            bus.Subscribe<ReaderSubscriptionManagement.CompleteSpooledStreamReading>(readerService);

            if (output_ != null)
            {
                bus.Subscribe(new UnwrapEnvelopeHandler());
                output_.Subscribe(Forwarder.Create<CoreProjectionStatusMessage.StateReport>(GetInputQueue()));
                output_.Subscribe(Forwarder.Create<CoreProjectionStatusMessage.ResultReport>(GetInputQueue()));
                output_.Subscribe(Forwarder.Create<CoreProjectionStatusMessage.StatisticsReport>(GetInputQueue()));
                output_.Subscribe(Forwarder.Create<CoreProjectionStatusMessage.Started>(GetInputQueue()));
                output_.Subscribe(Forwarder.Create<CoreProjectionStatusMessage.Stopped>(GetInputQueue()));
                output_.Subscribe(Forwarder.Create<CoreProjectionStatusMessage.Faulted>(GetInputQueue()));
                output_.Subscribe(Forwarder.Create<CoreProjectionStatusMessage.Prepared>(GetInputQueue()));
                output_.Subscribe(
                    Forwarder.Create<CoreProjectionManagementMessage.SlaveProjectionReaderAssigned>(GetInputQueue()));
                output_.Subscribe(Forwarder.Create<CoreProjectionStatusMessage.ProjectionWorkerStarted>(GetInputQueue()));
                output_.Subscribe(Forwarder.Create<ProjectionManagementMessage.Command.ControlMessage>(GetInputQueue()));
                output_.Subscribe(Forwarder.Create<AwakeServiceMessage.SubscribeAwake>(GetInputQueue()));
                output_.Subscribe(Forwarder.Create<AwakeServiceMessage.UnsubscribeAwake>(GetInputQueue()));
                output_.Subscribe(Forwarder.Create<PartitionProcessingResultBase>(GetInputQueue()));
                output_.Subscribe(Forwarder.Create<ReaderSubscriptionManagement.SpoolStreamReading>(GetInputQueue()));
                output_.Subscribe(Forwarder.Create<PartitionProcessingResultOutputBase>(GetInputQueue()));
                output_.Subscribe(Forwarder.Create<Message>(inputQueue)); // forward all

                var forwarder = new RequestResponseQueueForwarder(
                    inputQueue: inputQueue,
                    externalRequestQueue: GetInputQueue());
                // forwarded messages
                output_.Subscribe<ClientMessage.ReadEvent>(forwarder);
                output_.Subscribe<ClientMessage.ReadStreamEventsBackward>(forwarder);
                output_.Subscribe<ClientMessage.ReadStreamEventsForward>(forwarder);
                output_.Subscribe<ClientMessage.ReadAllEventsForward>(forwarder);
                output_.Subscribe<ClientMessage.WriteEvents>(forwarder);

            }
        }
 public void Setup()
 {
     _consumer = new TestHandler<Message>();
     _bus = new InMemoryBus("temp");
     _bus.Subscribe(_consumer);
     ICheckpoint writerCheckpoint = new InMemoryCheckpoint(1000);
     _readerService = new EventReaderCoreService(_bus, 10, writerCheckpoint, runHeadingReader: true);
     _subscriptionDispatcher =
         new PublishSubscribeDispatcher
             <ReaderSubscriptionManagement.Subscribe,
                 ReaderSubscriptionManagement.ReaderSubscriptionManagementMessage, EventReaderSubscriptionMessage
                 >(_bus, v => v.SubscriptionId, v => v.SubscriptionId);
     _service = new ProjectionCoreService(_bus, _bus, _subscriptionDispatcher, new RealTimeProvider());
     _bus.Subscribe(_subscriptionDispatcher.CreateSubscriber<EventReaderSubscriptionMessage.CheckpointSuggested>());
     _bus.Subscribe(_subscriptionDispatcher.CreateSubscriber<EventReaderSubscriptionMessage.CommittedEventReceived>());
     _bus.Subscribe(_subscriptionDispatcher.CreateSubscriber<EventReaderSubscriptionMessage.EofReached>());
     _bus.Subscribe(_subscriptionDispatcher.CreateSubscriber<EventReaderSubscriptionMessage.ProgressChanged>());
     _bus.Subscribe(_subscriptionDispatcher.CreateSubscriber<EventReaderSubscriptionMessage.NotAuthorized>());
     _readerService.Handle(new Messages.ReaderCoreServiceMessage.StartReader());
     _service.Handle(new ProjectionCoreServiceMessage.StartCore());
 }
        private void SetUpCoreServices(
            Guid workerId,
            IBus bus,
            IPublisher inputQueue,
            InMemoryBus output_,
            ISingletonTimeoutScheduler timeoutScheduler)
        {
            var         output           = (output_ ?? inputQueue);
            ICheckpoint writerCheckpoint = new InMemoryCheckpoint(1000);
            var         readerService    = new EventReaderCoreService(
                output,
                _ioDispatcher,
                10,
                writerCheckpoint,
                runHeadingReader: true, faultOutOfOrderProjections: true);

            _subscriptionDispatcher = new ReaderSubscriptionDispatcher(inputQueue);

            bus.Subscribe(
                _subscriptionDispatcher.CreateSubscriber <EventReaderSubscriptionMessage.CheckpointSuggested>());
            bus.Subscribe(
                _subscriptionDispatcher.CreateSubscriber <EventReaderSubscriptionMessage.CommittedEventReceived>());
            bus.Subscribe(_subscriptionDispatcher.CreateSubscriber <EventReaderSubscriptionMessage.EofReached>());
            bus.Subscribe(
                _subscriptionDispatcher.CreateSubscriber <EventReaderSubscriptionMessage.PartitionEofReached>());
            bus.Subscribe(_subscriptionDispatcher.CreateSubscriber <EventReaderSubscriptionMessage.PartitionDeleted>());
            bus.Subscribe(_subscriptionDispatcher.CreateSubscriber <EventReaderSubscriptionMessage.ProgressChanged>());
            bus.Subscribe(
                _subscriptionDispatcher.CreateSubscriber <EventReaderSubscriptionMessage.SubscriptionStarted>());
            bus.Subscribe(_subscriptionDispatcher.CreateSubscriber <EventReaderSubscriptionMessage.NotAuthorized>());
            bus.Subscribe(
                _subscriptionDispatcher.CreateSubscriber <EventReaderSubscriptionMessage.ReaderAssignedReader>());

            var ioDispatcher = new IODispatcher(output, new PublishEnvelope(inputQueue), true);
//            var coreServiceCommandReader = new ProjectionCoreServiceCommandReader(
//                output,
//                ioDispatcher,
//                workerId.ToString("N"));

            var coreService = new ProjectionCoreService(
                workerId,
                inputQueue,
                output,
                _subscriptionDispatcher,
                _timeProvider,
                ioDispatcher,
                timeoutScheduler);

            bus.Subscribe <CoreProjectionManagementMessage.CreateAndPrepare>(coreService);
            bus.Subscribe <CoreProjectionManagementMessage.CreatePrepared>(coreService);
            bus.Subscribe <CoreProjectionManagementMessage.Dispose>(coreService);
            bus.Subscribe <CoreProjectionManagementMessage.Start>(coreService);
            bus.Subscribe <CoreProjectionManagementMessage.LoadStopped>(coreService);
            bus.Subscribe <CoreProjectionManagementMessage.Stop>(coreService);
            bus.Subscribe <CoreProjectionManagementMessage.Kill>(coreService);
            bus.Subscribe <CoreProjectionManagementMessage.GetState>(coreService);
            bus.Subscribe <CoreProjectionManagementMessage.GetResult>(coreService);
            bus.Subscribe <CoreProjectionProcessingMessage.CheckpointCompleted>(coreService);
            bus.Subscribe <CoreProjectionProcessingMessage.CheckpointLoaded>(coreService);
            bus.Subscribe <CoreProjectionProcessingMessage.PrerecordedEventsLoaded>(coreService);
            bus.Subscribe <CoreProjectionProcessingMessage.RestartRequested>(coreService);
            bus.Subscribe <CoreProjectionProcessingMessage.Failed>(coreService);
            bus.Subscribe <ClientMessage.ReadStreamEventsForwardCompleted>(ioDispatcher.ForwardReader);
            bus.Subscribe <ClientMessage.ReadStreamEventsBackwardCompleted>(ioDispatcher.BackwardReader);
            bus.Subscribe <ClientMessage.WriteEventsCompleted>(ioDispatcher.Writer);
            bus.Subscribe <ClientMessage.DeleteStreamCompleted>(ioDispatcher.StreamDeleter);
            bus.Subscribe <IODispatcherDelayedMessage>(ioDispatcher.Awaker);
            bus.Subscribe <IODispatcherDelayedMessage>(ioDispatcher);
            bus.Subscribe <ProjectionCoreServiceMessage.StartCore>(coreService);
            bus.Subscribe <ProjectionCoreServiceMessage.StopCore>(coreService);
            bus.Subscribe <ReaderCoreServiceMessage.StartReader>(readerService);
            bus.Subscribe <ReaderCoreServiceMessage.StopReader>(readerService);
            bus.Subscribe <ProjectionCoreServiceMessage.CoreTick>(coreService);
            bus.Subscribe <ReaderSubscriptionMessage.CommittedEventDistributed>(readerService);
            bus.Subscribe <ReaderSubscriptionMessage.EventReaderEof>(readerService);
            bus.Subscribe <ReaderSubscriptionMessage.EventReaderPartitionEof>(readerService);
            bus.Subscribe <ReaderSubscriptionMessage.EventReaderPartitionDeleted>(readerService);
            bus.Subscribe <ReaderSubscriptionMessage.EventReaderNotAuthorized>(readerService);
            bus.Subscribe <ReaderSubscriptionMessage.EventReaderIdle>(readerService);
            bus.Subscribe <ReaderSubscriptionMessage.EventReaderStarting>(readerService);
            bus.Subscribe <ReaderSubscriptionManagement.Pause>(readerService);
            bus.Subscribe <ReaderSubscriptionManagement.Resume>(readerService);
            bus.Subscribe <ReaderSubscriptionManagement.Subscribe>(readerService);
            bus.Subscribe <ReaderSubscriptionManagement.Unsubscribe>(readerService);

            if (output_ != null)
            {
                bus.Subscribe(new UnwrapEnvelopeHandler());
                output_.Subscribe(Forwarder.Create <CoreProjectionStatusMessage.StateReport>(GetInputQueue()));
                output_.Subscribe(Forwarder.Create <CoreProjectionStatusMessage.ResultReport>(GetInputQueue()));
                output_.Subscribe(Forwarder.Create <CoreProjectionStatusMessage.StatisticsReport>(GetInputQueue()));
                output_.Subscribe(Forwarder.Create <CoreProjectionStatusMessage.Started>(GetInputQueue()));
                output_.Subscribe(Forwarder.Create <CoreProjectionStatusMessage.Stopped>(GetInputQueue()));
                output_.Subscribe(Forwarder.Create <CoreProjectionStatusMessage.Faulted>(GetInputQueue()));
                output_.Subscribe(Forwarder.Create <CoreProjectionStatusMessage.Prepared>(GetInputQueue()));
                output_.Subscribe(
                    Forwarder.Create <ProjectionManagementMessage.Command.ControlMessage>(GetInputQueue()));
                output_.Subscribe(Forwarder.Create <AwakeServiceMessage.SubscribeAwake>(GetInputQueue()));
                output_.Subscribe(Forwarder.Create <AwakeServiceMessage.UnsubscribeAwake>(GetInputQueue()));
                output_.Subscribe(Forwarder.Create <Message>(inputQueue));                // forward all

                var forwarder = new RequestResponseQueueForwarder(
                    inputQueue: inputQueue,
                    externalRequestQueue: GetInputQueue());
                // forwarded messages
                output_.Subscribe <ClientMessage.ReadEvent>(forwarder);
                output_.Subscribe <ClientMessage.ReadStreamEventsBackward>(forwarder);
                output_.Subscribe <ClientMessage.ReadStreamEventsForward>(forwarder);
                output_.Subscribe <ClientMessage.ReadAllEventsForward>(forwarder);
                output_.Subscribe <ClientMessage.WriteEvents>(forwarder);
            }
        }
Exemple #24
0
        public void Setup()
        {
            SetUpManualQueue();
            //TODO: this became an integration test - proper ProjectionCoreService and ProjectionManager testing is required as well
            _bus.Subscribe(_consumer);

            _manager = new ProjectionManager(
                GetInputQueue(), GetInputQueue(), new[] { GetInputQueue() }, _timeProvider, RunProjections.All,
                _initializeSystemProjections);
            ICheckpoint writerCheckpoint = new InMemoryCheckpoint(1000);

            _readerService          = new EventReaderCoreService(GetInputQueue(), 10, writerCheckpoint, runHeadingReader: true);
            _subscriptionDispatcher =
                new PublishSubscribeDispatcher
                <ReaderSubscriptionManagement.Subscribe,
                 ReaderSubscriptionManagement.ReaderSubscriptionManagementMessage, EventReaderSubscriptionMessage
                >(GetInputQueue(), v => v.SubscriptionId, v => v.SubscriptionId);

            _bus.Subscribe(_subscriptionDispatcher.CreateSubscriber <EventReaderSubscriptionMessage.CheckpointSuggested>());
            _bus.Subscribe(_subscriptionDispatcher.CreateSubscriber <EventReaderSubscriptionMessage.CommittedEventReceived>());
            _bus.Subscribe(_subscriptionDispatcher.CreateSubscriber <EventReaderSubscriptionMessage.EofReached>());
            _bus.Subscribe(_subscriptionDispatcher.CreateSubscriber <EventReaderSubscriptionMessage.ProgressChanged>());
            _bus.Subscribe(_subscriptionDispatcher.CreateSubscriber <EventReaderSubscriptionMessage.NotAuthorized>());

            _coreService = new ProjectionCoreService(GetInputQueue(), GetInputQueue(), _subscriptionDispatcher, _timeProvider);
            _bus.Subscribe <ProjectionManagementMessage.Internal.CleanupExpired>(_manager);
            _bus.Subscribe <ProjectionManagementMessage.Internal.Deleted>(_manager);
            _bus.Subscribe <CoreProjectionManagementMessage.Started>(_manager);
            _bus.Subscribe <CoreProjectionManagementMessage.Stopped>(_manager);
            _bus.Subscribe <CoreProjectionManagementMessage.Prepared>(_manager);
            _bus.Subscribe <CoreProjectionManagementMessage.Faulted>(_manager);
            _bus.Subscribe <CoreProjectionManagementMessage.StateReport>(_manager);
            _bus.Subscribe <CoreProjectionManagementMessage.ResultReport>(_manager);
            _bus.Subscribe <CoreProjectionManagementMessage.StatisticsReport>(_manager);
            _bus.Subscribe <ProjectionManagementMessage.Post>(_manager);
            _bus.Subscribe <ProjectionManagementMessage.UpdateQuery>(_manager);
            _bus.Subscribe <ProjectionManagementMessage.GetQuery>(_manager);
            _bus.Subscribe <ProjectionManagementMessage.Delete>(_manager);
            _bus.Subscribe <ProjectionManagementMessage.GetStatistics>(_manager);
            _bus.Subscribe <ProjectionManagementMessage.GetState>(_manager);
            _bus.Subscribe <ProjectionManagementMessage.GetResult>(_manager);
            _bus.Subscribe <ProjectionManagementMessage.Disable>(_manager);
            _bus.Subscribe <ProjectionManagementMessage.Enable>(_manager);
            _bus.Subscribe <ProjectionManagementMessage.SetRunAs>(_manager);
            _bus.Subscribe <ProjectionManagementMessage.Reset>(_manager);
            _bus.Subscribe <ClientMessage.WriteEventsCompleted>(_manager);
            _bus.Subscribe <ClientMessage.ReadStreamEventsBackwardCompleted>(_manager);
            _bus.Subscribe <ClientMessage.WriteEventsCompleted>(_manager);
            _bus.Subscribe <SystemMessage.StateChangeMessage>(_manager);

            _bus.Subscribe <CoreProjectionManagementMessage.CreateAndPrepare>(_coreService);
            _bus.Subscribe <CoreProjectionManagementMessage.CreatePrepared>(_coreService);
            _bus.Subscribe <CoreProjectionManagementMessage.Dispose>(_coreService);
            _bus.Subscribe <CoreProjectionManagementMessage.Start>(_coreService);
            _bus.Subscribe <CoreProjectionManagementMessage.LoadStopped>(_coreService);
            _bus.Subscribe <CoreProjectionManagementMessage.Stop>(_coreService);
            _bus.Subscribe <CoreProjectionManagementMessage.Kill>(_coreService);
            _bus.Subscribe <CoreProjectionManagementMessage.GetState>(_coreService);
            _bus.Subscribe <CoreProjectionManagementMessage.GetResult>(_coreService);
            _bus.Subscribe <CoreProjectionManagementMessage.UpdateStatistics>(_coreService);
            _bus.Subscribe <CoreProjectionProcessingMessage.CheckpointCompleted>(_coreService);
            _bus.Subscribe <CoreProjectionProcessingMessage.CheckpointLoaded>(_coreService);
            _bus.Subscribe <CoreProjectionProcessingMessage.PrerecordedEventsLoaded>(_coreService);
            _bus.Subscribe <CoreProjectionProcessingMessage.RestartRequested>(_coreService);
            _bus.Subscribe <CoreProjectionProcessingMessage.Failed>(_coreService);
            _bus.Subscribe <ClientMessage.ReadStreamEventsBackwardCompleted>(_coreService);
            _bus.Subscribe <ClientMessage.WriteEventsCompleted>(_coreService);
            _bus.Subscribe <ProjectionCoreServiceMessage.StartCore>(_coreService);
            _bus.Subscribe <ProjectionCoreServiceMessage.StopCore>(_coreService);
            _bus.Subscribe <ReaderCoreServiceMessage.StartReader>(_readerService);
            _bus.Subscribe <ReaderCoreServiceMessage.StopReader>(_readerService);
            _bus.Subscribe <ProjectionCoreServiceMessage.CoreTick>(_coreService);
            _bus.Subscribe <ReaderCoreServiceMessage.ReaderTick>(_readerService);
            _bus.Subscribe <ReaderSubscriptionMessage.CommittedEventDistributed>(_readerService);
            _bus.Subscribe <ReaderSubscriptionMessage.EventReaderEof>(_readerService);
            _bus.Subscribe <ReaderSubscriptionMessage.EventReaderNotAuthorized>(_readerService);
            _bus.Subscribe <ReaderSubscriptionMessage.EventReaderIdle>(_readerService);
            _bus.Subscribe <ReaderSubscriptionManagement.Pause>(_readerService);
            _bus.Subscribe <ReaderSubscriptionManagement.Resume>(_readerService);
            _bus.Subscribe <ReaderSubscriptionManagement.Subscribe>(_readerService);
            _bus.Subscribe <ReaderSubscriptionManagement.Unsubscribe>(_readerService);

            Given();
            WhenLoop();
        }
        public void Setup()
        {
            SetUpManualQueue();
            //TODO: this became an integration test - proper ProjectionCoreService and ProjectionManager testing is required as well
            _bus.Subscribe(_consumer);

            _manager = new ProjectionManager(
                GetInputQueue(), GetInputQueue(), new[] {GetInputQueue()}, _timeProvider, RunProjections.All,
                _initializeSystemProjections);
            ICheckpoint writerCheckpoint = new InMemoryCheckpoint(1000);
            _readerService = new EventReaderCoreService(GetInputQueue(), 10, writerCheckpoint, runHeadingReader: true);
            _subscriptionDispatcher =
                new PublishSubscribeDispatcher
                    <ReaderSubscriptionManagement.Subscribe,
                        ReaderSubscriptionManagement.ReaderSubscriptionManagementMessage, EventReaderSubscriptionMessage
                        >(GetInputQueue(), v => v.SubscriptionId, v => v.SubscriptionId);

            _bus.Subscribe(_subscriptionDispatcher.CreateSubscriber<EventReaderSubscriptionMessage.CheckpointSuggested>());
            _bus.Subscribe(_subscriptionDispatcher.CreateSubscriber<EventReaderSubscriptionMessage.CommittedEventReceived>());
            _bus.Subscribe(_subscriptionDispatcher.CreateSubscriber<EventReaderSubscriptionMessage.EofReached>());
            _bus.Subscribe(_subscriptionDispatcher.CreateSubscriber<EventReaderSubscriptionMessage.ProgressChanged>());
            _bus.Subscribe(_subscriptionDispatcher.CreateSubscriber<EventReaderSubscriptionMessage.NotAuthorized>());

            _coreService = new ProjectionCoreService(GetInputQueue(), GetInputQueue(), _subscriptionDispatcher, _timeProvider);
            _bus.Subscribe<ProjectionManagementMessage.Internal.CleanupExpired>(_manager);
            _bus.Subscribe<ProjectionManagementMessage.Internal.Deleted>(_manager);
            _bus.Subscribe<CoreProjectionManagementMessage.Started>(_manager);
            _bus.Subscribe<CoreProjectionManagementMessage.Stopped>(_manager);
            _bus.Subscribe<CoreProjectionManagementMessage.Prepared>(_manager);
            _bus.Subscribe<CoreProjectionManagementMessage.Faulted>(_manager);
            _bus.Subscribe<CoreProjectionManagementMessage.StateReport>(_manager);
            _bus.Subscribe<CoreProjectionManagementMessage.ResultReport>(_manager);
            _bus.Subscribe<CoreProjectionManagementMessage.StatisticsReport>(_manager);
            _bus.Subscribe<ProjectionManagementMessage.Post>(_manager);
            _bus.Subscribe<ProjectionManagementMessage.UpdateQuery>(_manager);
            _bus.Subscribe<ProjectionManagementMessage.GetQuery>(_manager);
            _bus.Subscribe<ProjectionManagementMessage.Delete>(_manager);
            _bus.Subscribe<ProjectionManagementMessage.GetStatistics>(_manager);
            _bus.Subscribe<ProjectionManagementMessage.GetState>(_manager);
            _bus.Subscribe<ProjectionManagementMessage.GetResult>(_manager);
            _bus.Subscribe<ProjectionManagementMessage.Disable>(_manager);
            _bus.Subscribe<ProjectionManagementMessage.Enable>(_manager);
            _bus.Subscribe<ProjectionManagementMessage.SetRunAs>(_manager);
            _bus.Subscribe<ProjectionManagementMessage.Reset>(_manager);
            _bus.Subscribe<ClientMessage.WriteEventsCompleted>(_manager);
            _bus.Subscribe<ClientMessage.ReadStreamEventsBackwardCompleted>(_manager);
            _bus.Subscribe<ClientMessage.WriteEventsCompleted>(_manager);
            _bus.Subscribe<SystemMessage.StateChangeMessage>(_manager);

            _bus.Subscribe<CoreProjectionManagementMessage.CreateAndPrepare>(_coreService);
            _bus.Subscribe<CoreProjectionManagementMessage.CreatePrepared>(_coreService);
            _bus.Subscribe<CoreProjectionManagementMessage.Dispose>(_coreService);
            _bus.Subscribe<CoreProjectionManagementMessage.Start>(_coreService);
            _bus.Subscribe<CoreProjectionManagementMessage.LoadStopped>(_coreService);
            _bus.Subscribe<CoreProjectionManagementMessage.Stop>(_coreService);
            _bus.Subscribe<CoreProjectionManagementMessage.Kill>(_coreService);
            _bus.Subscribe<CoreProjectionManagementMessage.GetState>(_coreService);
            _bus.Subscribe<CoreProjectionManagementMessage.GetResult>(_coreService);
            _bus.Subscribe<CoreProjectionManagementMessage.UpdateStatistics>(_coreService);
            _bus.Subscribe<CoreProjectionProcessingMessage.CheckpointCompleted>(_coreService);
            _bus.Subscribe<CoreProjectionProcessingMessage.CheckpointLoaded>(_coreService);
            _bus.Subscribe<CoreProjectionProcessingMessage.PrerecordedEventsLoaded>(_coreService);
            _bus.Subscribe<CoreProjectionProcessingMessage.RestartRequested>(_coreService);
            _bus.Subscribe<CoreProjectionProcessingMessage.Failed>(_coreService);
            _bus.Subscribe<ClientMessage.ReadStreamEventsBackwardCompleted>(_coreService);
            _bus.Subscribe<ClientMessage.WriteEventsCompleted>(_coreService);
            _bus.Subscribe<ProjectionCoreServiceMessage.StartCore>(_coreService);
            _bus.Subscribe<ProjectionCoreServiceMessage.StopCore>(_coreService);
            _bus.Subscribe<ReaderCoreServiceMessage.StartReader>(_readerService);
            _bus.Subscribe<ReaderCoreServiceMessage.StopReader>(_readerService);
            _bus.Subscribe<ProjectionCoreServiceMessage.CoreTick>(_coreService);
            _bus.Subscribe<ReaderCoreServiceMessage.ReaderTick>(_readerService);
            _bus.Subscribe<ReaderSubscriptionMessage.CommittedEventDistributed>(_readerService);
            _bus.Subscribe<ReaderSubscriptionMessage.EventReaderEof>(_readerService);
            _bus.Subscribe<ReaderSubscriptionMessage.EventReaderNotAuthorized>(_readerService);
            _bus.Subscribe<ReaderSubscriptionMessage.EventReaderIdle>(_readerService);
            _bus.Subscribe<ReaderSubscriptionManagement.Pause>(_readerService);
            _bus.Subscribe<ReaderSubscriptionManagement.Resume>(_readerService);
            _bus.Subscribe<ReaderSubscriptionManagement.Subscribe>(_readerService);
            _bus.Subscribe<ReaderSubscriptionManagement.Unsubscribe>(_readerService);
            
            Given();
            WhenLoop();
        }