public void Setup()
        {
            queues = new List <FakePublisher>()
            {
                new FakePublisher()
            }.ToArray();
            publisher = new FakePublisher();

            _coordinator =
                new ProjectionCoreCoordinator(ProjectionType.None, timeoutScheduler, queues, publisher, envelope);

            // Start components
            _coordinator.Handle(new ProjectionSubsystemMessage.StartComponents(instanceCorrelationId));
            _coordinator.Handle(
                new ProjectionCoreServiceMessage.SubComponentStarted(EventReaderCoreService.SubComponentName,
                                                                     instanceCorrelationId));

            // Stop components but don't handle component stopped
            _coordinator.Handle(new ProjectionSubsystemMessage.StopComponents(instanceCorrelationId));

            var stopReader = queues[0].Messages.OfType <ReaderCoreServiceMessage.StopReader>().First();

            queueId = stopReader.QueueId;
            //clear queues for clearer testing
            queues[0].Messages.Clear();
        }
Exemple #2
0
        public void Setup()
        {
            queues = new List <FakePublisher>()
            {
                new FakePublisher()
            }.ToArray();
            publisher = new FakePublisher();

            _coordinator =
                new ProjectionCoreCoordinator(ProjectionType.All, timeoutScheduler, queues, publisher, envelope);

            // Start components
            _coordinator.Handle(new ProjectionSubsystemMessage.StartComponents(instanceCorrelationId));

            // All components started
            _coordinator.Handle(
                new ProjectionCoreServiceMessage.SubComponentStarted(EventReaderCoreService.SubComponentName,
                                                                     instanceCorrelationId));
            _coordinator.Handle(
                new ProjectionCoreServiceMessage.SubComponentStarted(ProjectionCoreService.SubComponentName,
                                                                     instanceCorrelationId));
            _coordinator.Handle(
                new ProjectionCoreServiceMessage.SubComponentStarted(
                    ProjectionCoreServiceCommandReader.SubComponentName, instanceCorrelationId));

            // Stop components, but don't handle any sub component stopped messages
            _coordinator.Handle(new ProjectionSubsystemMessage.StopComponents(instanceCorrelationId));

            //clear queues for clearer testing
            queues[0].Messages.Clear();
        }
        public void Setup()
        {
            queues = new List <FakePublisher>()
            {
                new FakePublisher()
            }.ToArray();
            publisher = new FakePublisher();

            _coordinator =
                new ProjectionCoreCoordinator(ProjectionType.System, timeoutScheduler, queues, publisher, envelope);
            _coordinator.Handle(new ProjectionSubsystemMessage.StartComponents(Guid.NewGuid()));
        }
Exemple #4
0
        public void Setup()
        {
            queues = new List <FakePublisher>()
            {
                new FakePublisher()
            }.ToArray();
            publisher = new FakePublisher();

            _coordinator = new ProjectionCoreCoordinator(ProjectionType.None, timeoutScheduler, queues, publisher, envelope);
            _coordinator.Handle(new SystemMessage.BecomeMaster(Guid.NewGuid()));
            _coordinator.Handle(new SystemMessage.SystemCoreReady());
            _coordinator.Handle(new SystemMessage.EpochWritten(new EpochRecord(0, 0, Guid.NewGuid(), 0, DateTime.Now)));
        }
        public void Setup()
        {
            queues = new List <FakePublisher>()
            {
                new FakePublisher()
            }.ToArray();
            publisher = new FakePublisher();

            _coordinator = new ProjectionCoreCoordinator(ProjectionType.System, timeoutScheduler, queues, publisher, envelope);
            _coordinator.Handle(new SystemMessage.SystemCoreReady());
            _coordinator.Handle(new SystemMessage.BecomeMaster(Guid.NewGuid()));
            _coordinator.Handle(new SystemMessage.EpochWritten(new EpochRecord(0, 0, Guid.NewGuid(), 0, DateTime.Now)));

            //force stop
            _coordinator.Handle(new SystemMessage.BecomeUnknown(Guid.NewGuid()));

            //clear queues for clearer testing
            queues[0].Messages.Clear();
        }
        public void Setup()
        {
            queues = new List <FakePublisher>()
            {
                new FakePublisher()
            }.ToArray();
            publisher = new FakePublisher();

            var instanceCorrelationId = Guid.NewGuid();

            _coordinator =
                new ProjectionCoreCoordinator(ProjectionType.System, timeoutScheduler, queues, publisher, envelope);

            // Start components
            _coordinator.Handle(new ProjectionSubsystemMessage.StartComponents(instanceCorrelationId));

            // Start all sub components
            _coordinator.Handle(
                new ProjectionCoreServiceMessage.SubComponentStarted(EventReaderCoreService.SubComponentName,
                                                                     instanceCorrelationId));
            _coordinator.Handle(
                new ProjectionCoreServiceMessage.SubComponentStarted(ProjectionCoreService.SubComponentName,
                                                                     instanceCorrelationId));
            _coordinator.Handle(
                new ProjectionCoreServiceMessage.SubComponentStarted(
                    ProjectionCoreServiceCommandReader.SubComponentName, instanceCorrelationId));

            // Stop components
            _coordinator.Handle(new ProjectionSubsystemMessage.StopComponents(instanceCorrelationId));

            // Publish SubComponent stopped messages for the projection core service
            stopCoreMessages = queues[0].Messages
                               .FindAll(x => x.GetType() == typeof(ProjectionCoreServiceMessage.StopCore))
                               .Select(x => x as ProjectionCoreServiceMessage.StopCore)
                               .ToList();
            foreach (var msg in stopCoreMessages)
            {
                _coordinator.Handle(
                    new ProjectionCoreServiceMessage.SubComponentStopped(ProjectionCoreService.SubComponentName,
                                                                         msg.QueueId));
            }
        }
        public void Setup()
        {
            queues = new List <FakePublisher>()
            {
                new FakePublisher()
            }.ToArray();
            publisher = new FakePublisher();

            var instanceCorrelationId = Guid.NewGuid();

            _coordinator =
                new ProjectionCoreCoordinator(ProjectionType.None, timeoutScheduler, queues, publisher, envelope);

            // Start components
            _coordinator.Handle(new ProjectionSubsystemMessage.StartComponents(instanceCorrelationId));

            // start sub components
            _coordinator.Handle(
                new ProjectionCoreServiceMessage.SubComponentStarted(EventReaderCoreService.SubComponentName,
                                                                     instanceCorrelationId));

            //force stop
            _coordinator.Handle(new ProjectionSubsystemMessage.StopComponents(instanceCorrelationId));
        }
        public static Dictionary<Guid, QueuedHandler> CreateCoreWorkers(
            StandardComponents standardComponents,
            ProjectionsStandardComponents projectionsStandardComponents)
        {
            var coreTimeoutSchedulers =
                CreateTimeoutSchedulers(projectionsStandardComponents.ProjectionWorkerThreadCount);

            var coreQueues = new Dictionary<Guid, QueuedHandler>();
            while (coreQueues.Count < projectionsStandardComponents.ProjectionWorkerThreadCount)
            {
                var coreInputBus = new InMemoryBus("bus");
                var coreQueue = new QueuedHandler(
                    coreInputBus,
                    "Projection Core #" + coreQueues.Count,
                    groupName: "Projection Core");
                var workerId = Guid.NewGuid();
                var projectionNode = new ProjectionWorkerNode(
                    workerId,
                    standardComponents.Db,
                    coreQueue,
                    standardComponents.TimeProvider,
                    coreTimeoutSchedulers[coreQueues.Count],
                    projectionsStandardComponents.RunProjections);
                projectionNode.SetupMessaging(coreInputBus);

                var forwarder = new RequestResponseQueueForwarder(
                    inputQueue: coreQueue,
                    externalRequestQueue: standardComponents.MainQueue);
                // forwarded messages
                var coreOutput = projectionNode.CoreOutput;
                coreOutput.Subscribe<ClientMessage.ReadEvent>(forwarder);
                coreOutput.Subscribe<ClientMessage.ReadStreamEventsBackward>(forwarder);
                coreOutput.Subscribe<ClientMessage.ReadStreamEventsForward>(forwarder);
                coreOutput.Subscribe<ClientMessage.ReadAllEventsForward>(forwarder);
                coreOutput.Subscribe<ClientMessage.WriteEvents>(forwarder);
                coreOutput.Subscribe<ClientMessage.DeleteStream>(forwarder);


                if (projectionsStandardComponents.RunProjections >= ProjectionType.System)
                {
                    var slaveProjectionResponseWriter = projectionNode.SlaveProjectionResponseWriter;
                    coreOutput.Subscribe<PartitionMeasuredOutput>(slaveProjectionResponseWriter);
                    coreOutput.Subscribe<PartitionProcessingProgressOutput>(slaveProjectionResponseWriter);
                    coreOutput.Subscribe<PartitionProcessingResultOutput>(slaveProjectionResponseWriter);
                    coreOutput.Subscribe<ReaderSubscriptionManagement.SpoolStreamReading>(slaveProjectionResponseWriter);


                    coreOutput.Subscribe(
                        Forwarder.Create<AwakeServiceMessage.SubscribeAwake>(standardComponents.MainQueue));
                    coreOutput.Subscribe(
                        Forwarder.Create<AwakeServiceMessage.UnsubscribeAwake>(standardComponents.MainQueue));
                }
                coreOutput.Subscribe<TimerMessage.Schedule>(standardComponents.TimerService);


                coreOutput.Subscribe(Forwarder.Create<Message>(coreQueue)); // forward all

                coreInputBus.Subscribe(new UnwrapEnvelopeHandler());

                coreQueues.Add(workerId, coreQueue);
            }
            var queues = coreQueues.Select(v => v.Value).Cast<IPublisher>().ToArray();
            var coordinator = new ProjectionCoreCoordinator(
                projectionsStandardComponents.RunProjections,
                coreTimeoutSchedulers,
                queues,
                projectionsStandardComponents.MasterOutputBus,
                new PublishEnvelope(projectionsStandardComponents.MasterInputQueue, crossThread: true));

            coordinator.SetupMessaging(projectionsStandardComponents.MasterMainBus);
            projectionsStandardComponents.MasterMainBus.Subscribe(
                Forwarder.CreateBalancing<FeedReaderMessage.ReadPage>(coreQueues.Values.Cast<IPublisher>().ToArray()));
            return coreQueues;
        }
        public void Setup()
        {
            //TODO: this became an integration test - proper ProjectionCoreService and ProjectionManager testing is required as well
            _bus.Subscribe(_consumer);

            _processingQueues = GivenProcessingQueues();
            var queues = _processingQueues.ToDictionary(v => v.Item5, v => (IPublisher)v.Item1);
            _managerMessageDispatcher = new ProjectionManagerMessageDispatcher(queues);
            _manager = new ProjectionManager(
                GetInputQueue(),
                GetInputQueue(),
                queues,
                _timeProvider,
                ProjectionType.All,
                _ioDispatcher,
                _initializeSystemProjections);

            _coordinator = new ProjectionCoreCoordinator(
                ProjectionType.All,
                ProjectionCoreWorkersNode.CreateTimeoutSchedulers(queues.Count),
                queues.Values.ToArray(),
                _bus,
                Envelope);

            _bus.Subscribe<ProjectionManagementMessage.Internal.CleanupExpired>(_manager);
            _bus.Subscribe<ProjectionManagementMessage.Internal.Deleted>(_manager);
            _bus.Subscribe<CoreProjectionStatusMessage.Started>(_manager);
            _bus.Subscribe<CoreProjectionStatusMessage.Stopped>(_manager);
            _bus.Subscribe<CoreProjectionStatusMessage.Prepared>(_manager);
            _bus.Subscribe<CoreProjectionStatusMessage.Faulted>(_manager);
            _bus.Subscribe<CoreProjectionStatusMessage.StateReport>(_manager);
            _bus.Subscribe<CoreProjectionStatusMessage.ResultReport>(_manager);
            _bus.Subscribe<CoreProjectionStatusMessage.StatisticsReport>(_manager);
            _bus.Subscribe<CoreProjectionManagementMessage.SlaveProjectionReaderAssigned>(_manager);
            _bus.Subscribe<CoreProjectionStatusMessage.ProjectionWorkerStarted>(_manager);
            _bus.Subscribe<ProjectionManagementMessage.Command.Post>(_manager);
            _bus.Subscribe<ProjectionManagementMessage.Command.UpdateQuery>(_manager);
            _bus.Subscribe<ProjectionManagementMessage.Command.GetQuery>(_manager);
            _bus.Subscribe<ProjectionManagementMessage.Command.Delete>(_manager);
            _bus.Subscribe<ProjectionManagementMessage.Command.GetStatistics>(_manager);
            _bus.Subscribe<ProjectionManagementMessage.Command.GetState>(_manager);
            _bus.Subscribe<ProjectionManagementMessage.Command.GetResult>(_manager);
            _bus.Subscribe<ProjectionManagementMessage.Command.Disable>(_manager);
            _bus.Subscribe<ProjectionManagementMessage.Command.Enable>(_manager);
            _bus.Subscribe<ProjectionManagementMessage.Command.Abort>(_manager);
            _bus.Subscribe<ProjectionManagementMessage.Command.SetRunAs>(_manager);
            _bus.Subscribe<ProjectionManagementMessage.Command.Reset>(_manager);
            _bus.Subscribe<ProjectionManagementMessage.Command.StartSlaveProjections>(_manager);
            _bus.Subscribe<ClientMessage.WriteEventsCompleted>(_manager);
            _bus.Subscribe<ClientMessage.ReadStreamEventsBackwardCompleted>(_manager);
            _bus.Subscribe<ClientMessage.DeleteStreamCompleted>(_manager);
            _bus.Subscribe<SystemMessage.StateChangeMessage>(_manager);
            _bus.Subscribe<SystemMessage.SystemCoreReady>(_manager);
            _bus.Subscribe<ProjectionManagementMessage.ReaderReady>(_manager);
            _bus.Subscribe(
                CallbackSubscriber.Create<ProjectionManagementMessage.Starting>(
                    starting => _queue.Publish(new ProjectionManagementMessage.ReaderReady())));

            _bus.Subscribe<SystemMessage.StateChangeMessage>(_coordinator);
            _bus.Subscribe<SystemMessage.SystemCoreReady>(_coordinator);

            if (GetInputQueue() != _processingQueues.First().Item2)
            {
                _bus.Subscribe<PartitionProcessingResultBase>(_managerMessageDispatcher);
                _bus.Subscribe<CoreProjectionManagementControlMessage>(
                    _managerMessageDispatcher);
                _bus.Subscribe<PartitionProcessingResultOutputBase>(_managerMessageDispatcher);
                _bus.Subscribe<ReaderSubscriptionManagement.SpoolStreamReading>(_managerMessageDispatcher);
            }

            foreach(var q in _processingQueues)
                SetUpCoreServices(q.Item5, q.Item1, q.Item2, q.Item3, q.Item4);

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

            _processingQueues = GivenProcessingQueues();
            var queues = _processingQueues.ToDictionary(v => v.Item5, v => (IPublisher)v.Item1);

            _managerMessageDispatcher = new ProjectionManagerMessageDispatcher(queues);
            _manager = new ProjectionManager(
                GetInputQueue(),
                GetInputQueue(),
                queues,
                _timeProvider,
                ProjectionType.All,
                _ioDispatcher,
                TimeSpan.FromMinutes(Opts.ProjectionsQueryExpiryDefault),
                _initializeSystemProjections);

            _coordinator = new ProjectionCoreCoordinator(
                ProjectionType.All,
                ProjectionCoreWorkersNode.CreateTimeoutSchedulers(queues.Count),
                queues.Values.ToArray(),
                _bus,
                Envelope);

            _bus.Subscribe <ProjectionManagementMessage.Internal.CleanupExpired>(_manager);
            _bus.Subscribe <ProjectionManagementMessage.Internal.Deleted>(_manager);
            _bus.Subscribe <CoreProjectionStatusMessage.Started>(_manager);
            _bus.Subscribe <CoreProjectionStatusMessage.Stopped>(_manager);
            _bus.Subscribe <CoreProjectionStatusMessage.Prepared>(_manager);
            _bus.Subscribe <CoreProjectionStatusMessage.Faulted>(_manager);
            _bus.Subscribe <CoreProjectionStatusMessage.StateReport>(_manager);
            _bus.Subscribe <CoreProjectionStatusMessage.ResultReport>(_manager);
            _bus.Subscribe <CoreProjectionStatusMessage.StatisticsReport>(_manager);
            _bus.Subscribe <ProjectionManagementMessage.Command.Post>(_manager);
            _bus.Subscribe <ProjectionManagementMessage.Command.PostBatch>(_manager);
            _bus.Subscribe <ProjectionManagementMessage.Command.UpdateQuery>(_manager);
            _bus.Subscribe <ProjectionManagementMessage.Command.GetQuery>(_manager);
            _bus.Subscribe <ProjectionManagementMessage.Command.Delete>(_manager);
            _bus.Subscribe <ProjectionManagementMessage.Command.GetStatistics>(_manager);
            _bus.Subscribe <ProjectionManagementMessage.Command.GetState>(_manager);
            _bus.Subscribe <ProjectionManagementMessage.Command.GetResult>(_manager);
            _bus.Subscribe <ProjectionManagementMessage.Command.Disable>(_manager);
            _bus.Subscribe <ProjectionManagementMessage.Command.Enable>(_manager);
            _bus.Subscribe <ProjectionManagementMessage.Command.Abort>(_manager);
            _bus.Subscribe <ProjectionManagementMessage.Command.SetRunAs>(_manager);
            _bus.Subscribe <ProjectionManagementMessage.Command.Reset>(_manager);
            _bus.Subscribe <ClientMessage.WriteEventsCompleted>(_manager);
            _bus.Subscribe <ClientMessage.ReadStreamEventsForwardCompleted>(_manager);
            _bus.Subscribe <ClientMessage.ReadStreamEventsBackwardCompleted>(_manager);
            _bus.Subscribe <ClientMessage.DeleteStreamCompleted>(_manager);
            _bus.Subscribe <ProjectionSubsystemMessage.StartComponents>(_manager);
            _bus.Subscribe <ProjectionSubsystemMessage.StopComponents>(_manager);
            _bus.Subscribe <ProjectionSubsystemMessage.StartComponents>(_coordinator);
            _bus.Subscribe <ProjectionSubsystemMessage.StopComponents>(_coordinator);

            if (GetInputQueue() != _processingQueues.First().Item2)
            {
                _bus.Subscribe <CoreProjectionManagementControlMessage>(
                    _managerMessageDispatcher);
            }

            foreach (var q in _processingQueues)
            {
                SetUpCoreServices(q.Item5, q.Item1, q.Item2, q.Item3, q.Item4);
            }

            //Given();
            WhenLoop();
        }
        public static Dictionary <Guid, IQueuedHandler> CreateCoreWorkers(
            StandardComponents standardComponents,
            ProjectionsStandardComponents projectionsStandardComponents)
        {
            var coreTimeoutSchedulers =
                CreateTimeoutSchedulers(projectionsStandardComponents.ProjectionWorkerThreadCount);

            var coreQueues = new Dictionary <Guid, IQueuedHandler>();

            while (coreQueues.Count < projectionsStandardComponents.ProjectionWorkerThreadCount)
            {
                var coreInputBus = new InMemoryBus("bus");
                var coreQueue    = QueuedHandler.CreateQueuedHandler(coreInputBus,
                                                                     "Projection Core #" + coreQueues.Count,
                                                                     groupName: "Projection Core");
                var workerId       = Guid.NewGuid();
                var projectionNode = new ProjectionWorkerNode(
                    workerId,
                    standardComponents.Db,
                    coreQueue,
                    standardComponents.TimeProvider,
                    coreTimeoutSchedulers[coreQueues.Count],
                    projectionsStandardComponents.RunProjections);
                projectionNode.SetupMessaging(coreInputBus);

                var forwarder = new RequestResponseQueueForwarder(
                    inputQueue: coreQueue,
                    externalRequestQueue: standardComponents.MainQueue);
                // forwarded messages
                var coreOutput = projectionNode.CoreOutput;
                coreOutput.Subscribe <ClientMessage.ReadEvent>(forwarder);
                coreOutput.Subscribe <ClientMessage.ReadStreamEventsBackward>(forwarder);
                coreOutput.Subscribe <ClientMessage.ReadStreamEventsForward>(forwarder);
                coreOutput.Subscribe <ClientMessage.ReadAllEventsForward>(forwarder);
                coreOutput.Subscribe <ClientMessage.WriteEvents>(forwarder);
                coreOutput.Subscribe <ClientMessage.DeleteStream>(forwarder);


                if (projectionsStandardComponents.RunProjections >= ProjectionType.System)
                {
                    var slaveProjectionResponseWriter = projectionNode.SlaveProjectionResponseWriter;
                    coreOutput.Subscribe <PartitionMeasuredOutput>(slaveProjectionResponseWriter);
                    coreOutput.Subscribe <PartitionProcessingProgressOutput>(slaveProjectionResponseWriter);
                    coreOutput.Subscribe <PartitionProcessingResultOutput>(slaveProjectionResponseWriter);
                    coreOutput.Subscribe <ReaderSubscriptionManagement.SpoolStreamReading>(slaveProjectionResponseWriter);


                    coreOutput.Subscribe(
                        Forwarder.Create <AwakeServiceMessage.SubscribeAwake>(standardComponents.MainQueue));
                    coreOutput.Subscribe(
                        Forwarder.Create <AwakeServiceMessage.UnsubscribeAwake>(standardComponents.MainQueue));
                }
                coreOutput.Subscribe <TimerMessage.Schedule>(standardComponents.TimerService);


                coreOutput.Subscribe(Forwarder.Create <Message>(coreQueue)); // forward all

                coreInputBus.Subscribe(new UnwrapEnvelopeHandler());

                coreQueues.Add(workerId, coreQueue);
            }
            var queues      = coreQueues.Select(v => v.Value).Cast <IPublisher>().ToArray();
            var coordinator = new ProjectionCoreCoordinator(
                projectionsStandardComponents.RunProjections,
                coreTimeoutSchedulers,
                queues,
                projectionsStandardComponents.MasterOutputBus,
                new PublishEnvelope(projectionsStandardComponents.MasterInputQueue, crossThread: true));

            coordinator.SetupMessaging(projectionsStandardComponents.MasterMainBus);
            projectionsStandardComponents.MasterMainBus.Subscribe(
                Forwarder.CreateBalancing <FeedReaderMessage.ReadPage>(coreQueues.Values.Cast <IPublisher>().ToArray()));
            return(coreQueues);
        }
        public void Setup()
        {
            //TODO: this became an integration test - proper ProjectionCoreService and ProjectionManager testing is required as well
            _bus.Subscribe(_consumer);

            _processingQueues = GivenProcessingQueues();
            var queues = _processingQueues.ToDictionary(v => v.Item5, v => (IPublisher)v.Item1);

            _managerMessageDispatcher = new ProjectionManagerMessageDispatcher(queues);
            _manager = new ProjectionManager(
                GetInputQueue(),
                GetInputQueue(),
                queues,
                _timeProvider,
                ProjectionType.All,
                _initializeSystemProjections);

            _coordinator = new ProjectionCoreCoordinator(
                ProjectionType.All,
                ProjectionCoreWorkersNode.CreateTimeoutSchedulers(queues.Count),
                queues.Values.ToArray(),
                _bus,
                Envelope);

            _bus.Subscribe <ProjectionManagementMessage.Internal.CleanupExpired>(_manager);
            _bus.Subscribe <ProjectionManagementMessage.Internal.Deleted>(_manager);
            _bus.Subscribe <CoreProjectionStatusMessage.Started>(_manager);
            _bus.Subscribe <CoreProjectionStatusMessage.Stopped>(_manager);
            _bus.Subscribe <CoreProjectionStatusMessage.Prepared>(_manager);
            _bus.Subscribe <CoreProjectionStatusMessage.Faulted>(_manager);
            _bus.Subscribe <CoreProjectionStatusMessage.StateReport>(_manager);
            _bus.Subscribe <CoreProjectionStatusMessage.ResultReport>(_manager);
            _bus.Subscribe <CoreProjectionStatusMessage.StatisticsReport>(_manager);
            _bus.Subscribe <CoreProjectionManagementMessage.SlaveProjectionReaderAssigned>(_manager);
            _bus.Subscribe <CoreProjectionStatusMessage.ProjectionWorkerStarted>(_manager);
            _bus.Subscribe <ProjectionManagementMessage.Command.Post>(_manager);
            _bus.Subscribe <ProjectionManagementMessage.Command.UpdateQuery>(_manager);
            _bus.Subscribe <ProjectionManagementMessage.Command.GetQuery>(_manager);
            _bus.Subscribe <ProjectionManagementMessage.Command.Delete>(_manager);
            _bus.Subscribe <ProjectionManagementMessage.Command.GetStatistics>(_manager);
            _bus.Subscribe <ProjectionManagementMessage.Command.GetState>(_manager);
            _bus.Subscribe <ProjectionManagementMessage.Command.GetResult>(_manager);
            _bus.Subscribe <ProjectionManagementMessage.Command.Disable>(_manager);
            _bus.Subscribe <ProjectionManagementMessage.Command.Enable>(_manager);
            _bus.Subscribe <ProjectionManagementMessage.Command.Abort>(_manager);
            _bus.Subscribe <ProjectionManagementMessage.Command.SetRunAs>(_manager);
            _bus.Subscribe <ProjectionManagementMessage.Command.Reset>(_manager);
            _bus.Subscribe <ProjectionManagementMessage.Command.StartSlaveProjections>(_manager);
            _bus.Subscribe <ClientMessage.WriteEventsCompleted>(_manager);
            _bus.Subscribe <ClientMessage.ReadStreamEventsBackwardCompleted>(_manager);
            _bus.Subscribe <SystemMessage.StateChangeMessage>(_manager);
            _bus.Subscribe <SystemMessage.SystemCoreReady>(_manager);
            _bus.Subscribe <ProjectionManagementMessage.ReaderReady>(_manager);
            _bus.Subscribe(
                CallbackSubscriber.Create <ProjectionManagementMessage.Starting>(
                    starting => _queue.Publish(new ProjectionManagementMessage.ReaderReady())));

            _bus.Subscribe <SystemMessage.StateChangeMessage>(_coordinator);
            _bus.Subscribe <SystemMessage.SystemCoreReady>(_coordinator);

            if (GetInputQueue() != _processingQueues.First().Item2)
            {
                _bus.Subscribe <PartitionProcessingResultBase>(_managerMessageDispatcher);
                _bus.Subscribe <CoreProjectionManagementControlMessage>(
                    _managerMessageDispatcher);
                _bus.Subscribe <PartitionProcessingResultOutputBase>(_managerMessageDispatcher);
                _bus.Subscribe <ReaderSubscriptionManagement.SpoolStreamReading>(_managerMessageDispatcher);
            }

            foreach (var q in _processingQueues)
            {
                SetUpCoreServices(q.Item5, q.Item1, q.Item2, q.Item3, q.Item4);
            }

            //Given();
            WhenLoop();
        }