public void null_describe_source_throws_argument_null_exception()
 {
     var ps = new ProjectionSubscription(
         Guid.NewGuid(), CheckpointTag.FromPosition(0, -1),
         new TestMessageHandler<ProjectionMessage.Projections.CommittedEventReceived>(),
         new TestMessageHandler<ProjectionMessage.Projections.CheckpointSuggested>(), null, 1000);
 }
Example #2
0
 private void DispatchRecentMessagesTo(ProjectionSubscription subscription)
 {
     foreach (var m in _lastMessages)
     {
         subscription.Handle(m);
     }
 }
 public void null_ceckpoint_handler_throws_argument_null_exception()
 {
     var ps = new ProjectionSubscription(
         Guid.NewGuid(), CheckpointTag.FromPosition(0, -1),
         new TestMessageHandler<ProjectionMessage.Projections.CommittedEventReceived>(), null,
         CreateCheckpointStrategy(), 1000);
 }
        public void Handle(ProjectionSubscriptionManagement.Subscribe message)
        {
            if (_stopped)
            {
                return;
            }

            var fromCheckpointTag      = message.FromPosition;
            var projectionSubscription = new ProjectionSubscription(
                message.CorrelationId, fromCheckpointTag, message.Subscriber, message.Subscriber, message.Subscriber,
                message.CheckpointStrategy, message.CheckpointUnhandledBytesThreshold);

            _subscriptions.Add(message.CorrelationId, projectionSubscription);

            var distibutionPointCorrelationId = Guid.NewGuid();
            var eventDistributionPoint        = projectionSubscription.CreatePausedEventDistributionPoint(
                _publisher, distibutionPointCorrelationId);

            _logger.Trace(
                "The '{0}' projection subscribed to the '{1}' distribution point", message.CorrelationId,
                distibutionPointCorrelationId);
            _distributionPoints.Add(distibutionPointCorrelationId, eventDistributionPoint);
            _projectionDistributionPoints.Add(message.CorrelationId, distibutionPointCorrelationId);
            _distributionPointSubscriptions.Add(distibutionPointCorrelationId, message.CorrelationId);
            eventDistributionPoint.Resume();
        }
Example #5
0
        public void Handle(ProjectionMessage.Projections.SubscribeProjection message)
        {
            if (_stopped)
            {
                return;
            }

            var fromCheckpointTag      = message.FromPosition;
            var projectionSubscription = new ProjectionSubscription(
                message.CorrelationId, fromCheckpointTag, message.Subscriber, message.Subscriber,
                message.CheckpointStrategy, message.CheckpointUnhandledBytesThreshold);

            _projections.Add(message.CorrelationId, projectionSubscription);

            bool subscribedHeading = _headingEventDistributionPoint.TrySubscribe(
                message.CorrelationId, projectionSubscription, fromCheckpointTag);

            if (!subscribedHeading)
            {
                var distibutionPointCorrelationId = Guid.NewGuid();
                var eventDistributionPoint        = projectionSubscription.CreatePausedEventDistributionPoint(
                    _publisher, distibutionPointCorrelationId);
                _distributionPoints.Add(distibutionPointCorrelationId, eventDistributionPoint);
                _projectionDistributionPoints.Add(message.CorrelationId, distibutionPointCorrelationId);
                _distributionPointSubscriptions.Add(distibutionPointCorrelationId, message.CorrelationId);
                eventDistributionPoint.Resume();
            }
        }
 public void it_can_be_created()
 {
     var ps = new ProjectionSubscription(
         Guid.NewGuid(), CheckpointTag.FromPosition(0, -1),
         new TestMessageHandler<ProjectionMessage.Projections.CommittedEventReceived>(),
         new TestMessageHandler<ProjectionMessage.Projections.CheckpointSuggested>(), CreateCheckpointStrategy(),
         1000);
 }
Example #7
0
 private void AddSubscriber(Guid publishWithCorrelationId, ProjectionSubscription subscription)
 {
     _headSubscribers.Add(publishWithCorrelationId, subscription);
     if (_headDistributionPointPaused)
     {
         _headDistributionPointPaused = false;
         _headDistributionPoint.Resume();
     }
 }
 public void null_event_handler_throws_argument_null_exception()
 {
     var ps = new ProjectionSubscription(
         Guid.NewGuid(), Guid.NewGuid(), CheckpointTag.FromPosition(0, -1), null,
         new TestHandler<ProjectionSubscriptionMessage.CheckpointSuggested>(),
         new TestHandler<ProjectionSubscriptionMessage.ProgressChanged>(),
         new TestHandler<ProjectionSubscriptionMessage.EofReached>(),
         CreateCheckpointStrategy(),
         1000);
 }
 public bool TrySubscribe(Guid projectionId, ProjectionSubscription projectionSubscription, CheckpointTag fromCheckpointTag)
 {
     if (projectionSubscription.CanJoinAt(_subscribeFromPosition, fromCheckpointTag))
     {
         DispatchRecentMessagesTo(projectionSubscription);
         AddSubscriber(projectionId, projectionSubscription);
         return true;
     }
     return false;
 }
Example #10
0
 public bool TrySubscribe(Guid projectionId, ProjectionSubscription projectionSubscription, CheckpointTag fromCheckpointTag)
 {
     if (projectionSubscription.CanJoinAt(_subscribeFromPosition, fromCheckpointTag))
     {
         DispatchRecentMessagesTo(projectionSubscription);
         AddSubscriber(projectionId, projectionSubscription);
         return(true);
     }
     return(false);
 }
        public void setup()
        {
            _checkpointUnhandledBytesThreshold = 1000;
            Given();
            _bus = new FakePublisher();
            _projectionCorrelationId = Guid.NewGuid();
            _eventHandler = new TestMessageHandler<ProjectionMessage.Projections.CommittedEventReceived>();
            _checkpointHandler = new TestMessageHandler<ProjectionMessage.Projections.CheckpointSuggested>();
            _subscription = new ProjectionSubscription(
                _projectionCorrelationId, CheckpointTag.FromPosition(0, -1), _eventHandler, _checkpointHandler,
                CreateCheckpointStrategy(), _checkpointUnhandledBytesThreshold);

            When();
        }
 private void DispatchRecentMessagesTo(ProjectionSubscription subscription)
 {
     foreach (var m in _lastMessages)
         subscription.Handle(m);
 }
 private void AddSubscriber(Guid publishWithCorrelationId, ProjectionSubscription subscription)
 {
     _headSubscribers.Add(publishWithCorrelationId, subscription);
     if (_headDistributionPointPaused)
     {
         _headDistributionPointPaused = false;
         _headDistributionPoint.Resume();
     }
 }