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());
 }
        public void SetUp()
        {
            _subscriptionDispatcher =
                new ReaderSubscriptionDispatcher
                    (_bus);
            _bus.Subscribe(
                _subscriptionDispatcher.CreateSubscriber <EventReaderSubscriptionMessage.CommittedEventReceived>());
            _bus.Subscribe(
                _subscriptionDispatcher.CreateSubscriber <EventReaderSubscriptionMessage.CheckpointSuggested>());
            _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 <ProjectionCoreServiceMessage.CoreTick>(this);
            _bus.Subscribe <ReaderCoreServiceMessage.ReaderTick>(this);

            AwakeService = new AwakeService();
            _bus.Subscribe <StorageMessage.EventCommitted>(AwakeService);
            _bus.Subscribe <StorageMessage.TfEofAtNonCommitRecord>(AwakeService);
            _bus.Subscribe <AwakeServiceMessage.SubscribeAwake>(AwakeService);
            _bus.Subscribe <AwakeServiceMessage.UnsubscribeAwake>(AwakeService);
            _bus.Subscribe(new UnwrapEnvelopeHandler());
        }
Exemplo n.º 3
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.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());
        }
 public void setup()
 {
     _bus = new InMemoryBus("bus");
     _listEventsHandler = new TestHandler<ClientMessage.ReadStreamEventsBackward>();
     _bus.Subscribe(_listEventsHandler);
     _ioDispatcher = new IODispatcher(_bus, new PublishEnvelope(_bus));
     _subscriptionDispatcher =
         new ReaderSubscriptionDispatcher
             (_bus);
     _bus.Subscribe(
         _subscriptionDispatcher.CreateSubscriber<EventReaderSubscriptionMessage.CommittedEventReceived>());
     _bus.Subscribe(
         _subscriptionDispatcher.CreateSubscriber<EventReaderSubscriptionMessage.CheckpointSuggested>());
     _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(_ioDispatcher.BackwardReader);
     _bus.Subscribe(_ioDispatcher.ForwardReader);
     _bus.Subscribe(_ioDispatcher.Writer);
     _bus.Subscribe(_ioDispatcher);
     IProjectionStateHandler projectionStateHandler = new FakeProjectionStateHandler();
     _projectionConfig = new ProjectionConfig(null, 5, 10, 1000, 250, true, true, false, false, false);
     var version = new ProjectionVersion(1, 0, 0);
     var projectionProcessingStrategy = new ContinuousProjectionProcessingStrategy(
         "projection", version, projectionStateHandler, _projectionConfig,
         projectionStateHandler.GetSourceDefinition(), null, _subscriptionDispatcher);
     _coreProjection = projectionProcessingStrategy.Create(
         Guid.NewGuid(), _bus, SystemAccount.Principal, _bus, _ioDispatcher, _subscriptionDispatcher,
         new RealTimeProvider());
     _coreProjection.Start();
 }
Exemplo n.º 5
0
        public void Setup()
        {
            _bus.Subscribe(_consumer);

            ICheckpoint writerCheckpoint = new InMemoryCheckpoint(1000);

            _readerService = new EventReaderCoreService(
                GetInputQueue(), _ioDispatcher, 10, writerCheckpoint, runHeadingReader: GivenHeadingReaderRunning(),
                faultOutOfOrderProjections: true);
            _subscriptionDispatcher =
                new ReaderSubscriptionDispatcher(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.ProgressChanged>());
            _bus.Subscribe(
                _subscriptionDispatcher.CreateSubscriber <EventReaderSubscriptionMessage.SubscriptionStarted>());
            _bus.Subscribe(_subscriptionDispatcher.CreateSubscriber <EventReaderSubscriptionMessage.NotAuthorized>());
            _bus.Subscribe(
                _subscriptionDispatcher.CreateSubscriber <EventReaderSubscriptionMessage.ReaderAssignedReader>());


            _bus.Subscribe <ReaderCoreServiceMessage.StartReader>(_readerService);
            _bus.Subscribe <ReaderCoreServiceMessage.StopReader>(_readerService);
            _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.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);


            GivenAdditionalServices();


            _bus.Publish(new ReaderCoreServiceMessage.StartReader(Guid.NewGuid()));

            WhenLoop();
        }
Exemplo n.º 6
0
        public void setup()
        {
            _bus = new InMemoryBus("bus");
            _listEventsHandler = new TestHandler <ClientMessage.ReadStreamEventsBackward>();
            _bus.Subscribe(_listEventsHandler);
            _ioDispatcher           = new IODispatcher(_bus, new PublishEnvelope(_bus));
            _subscriptionDispatcher =
                new ReaderSubscriptionDispatcher
                    (_bus);
            _bus.Subscribe(
                _subscriptionDispatcher.CreateSubscriber <EventReaderSubscriptionMessage.CommittedEventReceived>());
            _bus.Subscribe(
                _subscriptionDispatcher.CreateSubscriber <EventReaderSubscriptionMessage.CheckpointSuggested>());
            _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(_ioDispatcher.BackwardReader);
            _bus.Subscribe(_ioDispatcher.ForwardReader);
            _bus.Subscribe(_ioDispatcher.Writer);
            _bus.Subscribe(_ioDispatcher);
            IProjectionStateHandler projectionStateHandler = new FakeProjectionStateHandler();

            _projectionConfig =
                new ProjectionConfig(null, 5, 10, 1000, 250, true, true, false, false, false, true, 10000, 1);
            var version = new ProjectionVersion(1, 0, 0);
            var projectionProcessingStrategy = new ContinuousProjectionProcessingStrategy(
                "projection", version, projectionStateHandler, _projectionConfig,
                projectionStateHandler.GetSourceDefinition(), null, _subscriptionDispatcher);

            _coreProjection = projectionProcessingStrategy.Create(
                Guid.NewGuid(),
                _bus,
                Guid.NewGuid(),
                SystemAccount.Principal,
                _bus,
                _ioDispatcher,
                _subscriptionDispatcher,
                new RealTimeProvider());
            _coreProjection.Start();
        }
 public void SetUp()
 {
     _subscriptionDispatcher = new ReaderSubscriptionDispatcher(
         _bus);
     _bus.Subscribe(
         _subscriptionDispatcher.CreateSubscriber<EventReaderSubscriptionMessage.CommittedEventReceived>());
     _bus.Subscribe(
         _subscriptionDispatcher.CreateSubscriber<EventReaderSubscriptionMessage.CheckpointSuggested>());
     _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>());
 }
 public void SetUp()
 {
     _subscriptionDispatcher = new ReaderSubscriptionDispatcher(
         _bus);
     _bus.Subscribe(
         _subscriptionDispatcher.CreateSubscriber <EventReaderSubscriptionMessage.CommittedEventReceived>());
     _bus.Subscribe(
         _subscriptionDispatcher.CreateSubscriber <EventReaderSubscriptionMessage.CheckpointSuggested>());
     _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>());
 }
        public void Setup()
        {
            _bus.Subscribe(_consumer);

            ICheckpoint writerCheckpoint = new InMemoryCheckpoint(1000);
            _readerService = new EventReaderCoreService(
                GetInputQueue(), _ioDispatcher, 10, writerCheckpoint, runHeadingReader: GivenHeadingReaderRunning());
            _subscriptionDispatcher =
                new ReaderSubscriptionDispatcher(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.ProgressChanged>());
            _bus.Subscribe(_subscriptionDispatcher.CreateSubscriber<EventReaderSubscriptionMessage.SubscriptionStarted>());
            _bus.Subscribe(_subscriptionDispatcher.CreateSubscriber<EventReaderSubscriptionMessage.NotAuthorized>());
            _bus.Subscribe(_subscriptionDispatcher.CreateSubscriber<EventReaderSubscriptionMessage.ReaderAssignedReader>());


            _bus.Subscribe<ReaderCoreServiceMessage.StartReader>(_readerService);
            _bus.Subscribe<ReaderCoreServiceMessage.StopReader>(_readerService);
            _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.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);


            GivenAdditionalServices();


            _bus.Publish(new ReaderCoreServiceMessage.StartReader());

            WhenLoop();
        }
Exemplo n.º 10
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));
        }
        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);

            }
        }
        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);
            }
        }
        public void SetupMessaging(IBus coreInputBus)
        {

            coreInputBus.Subscribe(_subscriptionDispatcher.CreateSubscriber<EventReaderSubscriptionMessage.CheckpointSuggested>());
            coreInputBus.Subscribe(_subscriptionDispatcher.CreateSubscriber<EventReaderSubscriptionMessage.CommittedEventReceived>());
            coreInputBus.Subscribe(_subscriptionDispatcher.CreateSubscriber<EventReaderSubscriptionMessage.EofReached>());
            coreInputBus.Subscribe(_subscriptionDispatcher.CreateSubscriber<EventReaderSubscriptionMessage.PartitionEofReached>());
            coreInputBus.Subscribe(_subscriptionDispatcher.CreateSubscriber<EventReaderSubscriptionMessage.PartitionMeasured>());
            coreInputBus.Subscribe(_subscriptionDispatcher.CreateSubscriber<EventReaderSubscriptionMessage.PartitionDeleted>());
            coreInputBus.Subscribe(_subscriptionDispatcher.CreateSubscriber<EventReaderSubscriptionMessage.ProgressChanged>());
            coreInputBus.Subscribe(_subscriptionDispatcher.CreateSubscriber<EventReaderSubscriptionMessage.SubscriptionStarted>());
            coreInputBus.Subscribe(_subscriptionDispatcher.CreateSubscriber<EventReaderSubscriptionMessage.NotAuthorized>());
            coreInputBus.Subscribe(_subscriptionDispatcher.CreateSubscriber<EventReaderSubscriptionMessage.ReaderAssignedReader>());
            coreInputBus.Subscribe(_subscriptionDispatcher.CreateSubscriber<EventReaderSubscriptionMessage.Failed>());
            coreInputBus.Subscribe(_spoolProcessingResponseDispatcher.CreateSubscriber<PartitionProcessingResult>());
            coreInputBus.Subscribe(_spoolProcessingResponseDispatcher.CreateSubscriber<PartitionMeasured>());
            coreInputBus.Subscribe(_spoolProcessingResponseDispatcher.CreateSubscriber<PartitionProcessingProgress>());
            
            coreInputBus.Subscribe(_feedReaderService);

            if (_runProjections >= ProjectionType.System)
            {

                coreInputBus.Subscribe<ProjectionCoreServiceMessage.StartCore>(_projectionCoreService);
                coreInputBus.Subscribe<ProjectionCoreServiceMessage.StopCore>(_projectionCoreService);
                coreInputBus.Subscribe<ProjectionCoreServiceMessage.StartCore>(_projectionCoreServiceCommandReader);
                coreInputBus.Subscribe<ProjectionCoreServiceMessage.StopCore>(_projectionCoreServiceCommandReader);
                coreInputBus.Subscribe<ProjectionCoreServiceMessage.CoreTick>(_projectionCoreService);
                coreInputBus.Subscribe<CoreProjectionManagementMessage.CreateAndPrepare>(_projectionCoreService);
                coreInputBus.Subscribe<CoreProjectionManagementMessage.CreatePrepared>(_projectionCoreService);
                coreInputBus.Subscribe<CoreProjectionManagementMessage.CreateAndPrepareSlave>(_projectionCoreService);
                coreInputBus.Subscribe<CoreProjectionManagementMessage.Dispose>(_projectionCoreService);
                coreInputBus.Subscribe<CoreProjectionManagementMessage.Start>(_projectionCoreService);
                coreInputBus.Subscribe<CoreProjectionManagementMessage.LoadStopped>(_projectionCoreService);
                coreInputBus.Subscribe<CoreProjectionManagementMessage.Stop>(_projectionCoreService);
                coreInputBus.Subscribe<CoreProjectionManagementMessage.Kill>(_projectionCoreService);
                coreInputBus.Subscribe<CoreProjectionManagementMessage.GetState>(_projectionCoreService);
                coreInputBus.Subscribe<CoreProjectionManagementMessage.GetResult>(_projectionCoreService);
                coreInputBus.Subscribe<ProjectionManagementMessage.SlaveProjectionsStarted>(_projectionCoreService);
                coreInputBus.Subscribe<ClientMessage.ReadStreamEventsForwardCompleted>(_ioDispatcher.ForwardReader);
                coreInputBus.Subscribe<ClientMessage.ReadStreamEventsBackwardCompleted>(_ioDispatcher.BackwardReader);
                coreInputBus.Subscribe<ClientMessage.WriteEventsCompleted>(_ioDispatcher.Writer);
                coreInputBus.Subscribe<ClientMessage.DeleteStreamCompleted>(_ioDispatcher.StreamDeleter);
                coreInputBus.Subscribe<IODispatcherDelayedMessage>(_ioDispatcher.Awaker);
                coreInputBus.Subscribe<IODispatcherDelayedMessage>(_ioDispatcher);
                coreInputBus.Subscribe<CoreProjectionProcessingMessage.CheckpointCompleted>(_projectionCoreService);
                coreInputBus.Subscribe<CoreProjectionProcessingMessage.CheckpointLoaded>(_projectionCoreService);
                coreInputBus.Subscribe<CoreProjectionProcessingMessage.PrerecordedEventsLoaded>(_projectionCoreService);
                coreInputBus.Subscribe<CoreProjectionProcessingMessage.RestartRequested>(_projectionCoreService);
                coreInputBus.Subscribe<CoreProjectionProcessingMessage.Failed>(_projectionCoreService);
                //NOTE: message forwarding is set up outside (for Read/Write events)

                coreInputBus.Subscribe<ProjectionCoreServiceMessage.StartCore>(_coreResponseWriter);
                coreInputBus.Subscribe<CoreProjectionStatusMessage.Faulted>(_coreResponseWriter);
                coreInputBus.Subscribe<CoreProjectionStatusMessage.Prepared>(_coreResponseWriter);
                coreInputBus.Subscribe<CoreProjectionManagementMessage.SlaveProjectionReaderAssigned>(_coreResponseWriter);
                coreInputBus.Subscribe<CoreProjectionStatusMessage.Started>(_coreResponseWriter);
                coreInputBus.Subscribe<CoreProjectionStatusMessage.StatisticsReport>(_coreResponseWriter);
                coreInputBus.Subscribe<CoreProjectionStatusMessage.Stopped>(_coreResponseWriter);
                coreInputBus.Subscribe<CoreProjectionStatusMessage.StateReport>(_coreResponseWriter);
                coreInputBus.Subscribe<CoreProjectionStatusMessage.ResultReport>(_coreResponseWriter);
                coreInputBus.Subscribe<ProjectionManagementMessage.Command.Abort>(_coreResponseWriter);
                coreInputBus.Subscribe<ProjectionManagementMessage.Command.Delete>(_coreResponseWriter);
                coreInputBus.Subscribe<ProjectionManagementMessage.Command.Disable>(_coreResponseWriter);
                coreInputBus.Subscribe<ProjectionManagementMessage.Command.Enable>(_coreResponseWriter);
                coreInputBus.Subscribe<ProjectionManagementMessage.Command.GetQuery>(_coreResponseWriter);
                coreInputBus.Subscribe<ProjectionManagementMessage.Command.GetResult>(_coreResponseWriter);
                coreInputBus.Subscribe<ProjectionManagementMessage.Command.GetState>(_coreResponseWriter);
                coreInputBus.Subscribe<ProjectionManagementMessage.Command.GetStatistics>(_coreResponseWriter);
                coreInputBus.Subscribe<ProjectionManagementMessage.Command.Post>(_coreResponseWriter);
                coreInputBus.Subscribe<ProjectionManagementMessage.Command.Reset>(_coreResponseWriter);
                coreInputBus.Subscribe<ProjectionManagementMessage.Command.SetRunAs>(_coreResponseWriter);
                coreInputBus.Subscribe<ProjectionManagementMessage.Command.StartSlaveProjections>(_coreResponseWriter);
                coreInputBus.Subscribe<ProjectionManagementMessage.Command.UpdateQuery>(_coreResponseWriter);
            }

            coreInputBus.Subscribe<ReaderCoreServiceMessage.ReaderTick>(_eventReaderCoreService);
            coreInputBus.Subscribe<ReaderCoreServiceMessage.StartReader>(_eventReaderCoreService);
            coreInputBus.Subscribe<ReaderCoreServiceMessage.StopReader>(_eventReaderCoreService);
            coreInputBus.Subscribe<ReaderSubscriptionManagement.Subscribe>(_eventReaderCoreService);
            coreInputBus.Subscribe<ReaderSubscriptionManagement.Unsubscribe>(_eventReaderCoreService);
            coreInputBus.Subscribe<ReaderSubscriptionManagement.Pause>(_eventReaderCoreService);
            coreInputBus.Subscribe<ReaderSubscriptionManagement.Resume>(_eventReaderCoreService);
            coreInputBus.Subscribe<ReaderSubscriptionManagement.SpoolStreamReadingCore>(_eventReaderCoreService);
            coreInputBus.Subscribe<ReaderSubscriptionManagement.CompleteSpooledStreamReading>(_eventReaderCoreService);
            coreInputBus.Subscribe<ReaderSubscriptionMessage.CommittedEventDistributed>(_eventReaderCoreService);
            coreInputBus.Subscribe<ReaderSubscriptionMessage.EventReaderIdle>(_eventReaderCoreService);
            coreInputBus.Subscribe<ReaderSubscriptionMessage.EventReaderStarting>(_eventReaderCoreService);
            coreInputBus.Subscribe<ReaderSubscriptionMessage.EventReaderEof>(_eventReaderCoreService);
            coreInputBus.Subscribe<ReaderSubscriptionMessage.EventReaderPartitionEof>(_eventReaderCoreService);
            coreInputBus.Subscribe<ReaderSubscriptionMessage.EventReaderPartitionDeleted>(_eventReaderCoreService);
            coreInputBus.Subscribe<ReaderSubscriptionMessage.EventReaderPartitionMeasured>(_eventReaderCoreService);
            coreInputBus.Subscribe<ReaderSubscriptionMessage.EventReaderNotAuthorized>(_eventReaderCoreService);
            //NOTE: message forwarding is set up outside (for Read/Write events)
        }
Exemplo n.º 14
0
        public void SetupMessaging(IBus coreInputBus)
        {
            coreInputBus.Subscribe(_subscriptionDispatcher
                                   .CreateSubscriber <EventReaderSubscriptionMessage.CheckpointSuggested>());
            coreInputBus.Subscribe(_subscriptionDispatcher
                                   .CreateSubscriber <EventReaderSubscriptionMessage.CommittedEventReceived>());
            coreInputBus.Subscribe(
                _subscriptionDispatcher.CreateSubscriber <EventReaderSubscriptionMessage.EofReached>());
            coreInputBus.Subscribe(_subscriptionDispatcher
                                   .CreateSubscriber <EventReaderSubscriptionMessage.PartitionEofReached>());
            coreInputBus.Subscribe(_subscriptionDispatcher
                                   .CreateSubscriber <EventReaderSubscriptionMessage.PartitionDeleted>());
            coreInputBus.Subscribe(_subscriptionDispatcher
                                   .CreateSubscriber <EventReaderSubscriptionMessage.ProgressChanged>());
            coreInputBus.Subscribe(_subscriptionDispatcher
                                   .CreateSubscriber <EventReaderSubscriptionMessage.SubscriptionStarted>());
            coreInputBus.Subscribe(_subscriptionDispatcher
                                   .CreateSubscriber <EventReaderSubscriptionMessage.NotAuthorized>());
            coreInputBus.Subscribe(_subscriptionDispatcher
                                   .CreateSubscriber <EventReaderSubscriptionMessage.ReaderAssignedReader>());
            coreInputBus.Subscribe(_subscriptionDispatcher.CreateSubscriber <EventReaderSubscriptionMessage.Failed>());

            coreInputBus.Subscribe(_feedReaderService);

            if (_runProjections >= ProjectionType.System)
            {
                coreInputBus.Subscribe <ProjectionCoreServiceMessage.StartCore>(_projectionCoreService);
                coreInputBus.Subscribe <ProjectionCoreServiceMessage.StopCore>(_projectionCoreService);
                coreInputBus.Subscribe <ProjectionCoreServiceMessage.StopCoreTimeout>(_projectionCoreService);
                coreInputBus.Subscribe <ProjectionCoreServiceMessage.CoreTick>(_projectionCoreService);
                coreInputBus.Subscribe <CoreProjectionManagementMessage.CreateAndPrepare>(_projectionCoreService);
                coreInputBus.Subscribe <CoreProjectionManagementMessage.CreatePrepared>(_projectionCoreService);
                coreInputBus.Subscribe <CoreProjectionManagementMessage.Dispose>(_projectionCoreService);
                coreInputBus.Subscribe <CoreProjectionManagementMessage.Start>(_projectionCoreService);
                coreInputBus.Subscribe <CoreProjectionManagementMessage.LoadStopped>(_projectionCoreService);
                coreInputBus.Subscribe <CoreProjectionManagementMessage.Stop>(_projectionCoreService);
                coreInputBus.Subscribe <CoreProjectionManagementMessage.Kill>(_projectionCoreService);
                coreInputBus.Subscribe <CoreProjectionManagementMessage.GetState>(_projectionCoreService);
                coreInputBus.Subscribe <CoreProjectionManagementMessage.GetResult>(_projectionCoreService);
                coreInputBus.Subscribe <ClientMessage.ReadStreamEventsForwardCompleted>(_ioDispatcher.ForwardReader);
                coreInputBus.Subscribe <ClientMessage.ReadStreamEventsBackwardCompleted>(_ioDispatcher.BackwardReader);
                coreInputBus.Subscribe <ClientMessage.ReadEventCompleted>(_ioDispatcher.EventReader);
                coreInputBus.Subscribe <ClientMessage.WriteEventsCompleted>(_ioDispatcher.Writer);
                coreInputBus.Subscribe <ClientMessage.DeleteStreamCompleted>(_ioDispatcher.StreamDeleter);
                coreInputBus.Subscribe <IODispatcherDelayedMessage>(_ioDispatcher.Awaker);
                coreInputBus.Subscribe <IODispatcherDelayedMessage>(_ioDispatcher);
                coreInputBus.Subscribe <CoreProjectionProcessingMessage.CheckpointCompleted>(_projectionCoreService);
                coreInputBus.Subscribe <CoreProjectionProcessingMessage.CheckpointLoaded>(_projectionCoreService);
                coreInputBus.Subscribe <CoreProjectionProcessingMessage.PrerecordedEventsLoaded>(_projectionCoreService);
                coreInputBus.Subscribe <CoreProjectionProcessingMessage.RestartRequested>(_projectionCoreService);
                coreInputBus.Subscribe <CoreProjectionProcessingMessage.Failed>(_projectionCoreService);
                coreInputBus.Subscribe <CoreProjectionStatusMessage.Suspended>(_projectionCoreService);
                //NOTE: message forwarding is set up outside (for Read/Write events)

                // Forward messages back to projection manager
                coreInputBus.Subscribe(
                    Forwarder.Create <ProjectionManagementMessage.Command.ControlMessage>(_leaderOutputBus));
                coreInputBus.Subscribe(
                    Forwarder.Create <CoreProjectionStatusMessage.CoreProjectionStatusMessageBase>(_leaderOutputBus));
                coreInputBus.Subscribe(
                    Forwarder.Create <CoreProjectionStatusMessage.DataReportBase>(_leaderOutputBus));
            }

            coreInputBus.Subscribe <ReaderCoreServiceMessage.StartReader>(_eventReaderCoreService);
            coreInputBus.Subscribe <ReaderCoreServiceMessage.StopReader>(_eventReaderCoreService);
            coreInputBus.Subscribe <ReaderSubscriptionManagement.Subscribe>(_eventReaderCoreService);
            coreInputBus.Subscribe <ReaderSubscriptionManagement.Unsubscribe>(_eventReaderCoreService);
            coreInputBus.Subscribe <ReaderSubscriptionManagement.Pause>(_eventReaderCoreService);
            coreInputBus.Subscribe <ReaderSubscriptionManagement.Resume>(_eventReaderCoreService);
            coreInputBus.Subscribe <ReaderSubscriptionMessage.CommittedEventDistributed>(_eventReaderCoreService);
            coreInputBus.Subscribe <ReaderSubscriptionMessage.EventReaderIdle>(_eventReaderCoreService);
            coreInputBus.Subscribe <ReaderSubscriptionMessage.EventReaderStarting>(_eventReaderCoreService);
            coreInputBus.Subscribe <ReaderSubscriptionMessage.EventReaderEof>(_eventReaderCoreService);
            coreInputBus.Subscribe <ReaderSubscriptionMessage.EventReaderPartitionEof>(_eventReaderCoreService);
            coreInputBus.Subscribe <ReaderSubscriptionMessage.EventReaderPartitionDeleted>(_eventReaderCoreService);
            coreInputBus.Subscribe <ReaderSubscriptionMessage.EventReaderNotAuthorized>(_eventReaderCoreService);
            coreInputBus.Subscribe <ReaderSubscriptionMessage.Faulted>(_eventReaderCoreService);
            //NOTE: message forwarding is set up outside (for Read/Write events)
        }