コード例 #1
0
 private async Task SubscribeToStreamAsync()
 {
     if (!ShouldStop)
     {
         if (Verbose)
         {
             Log.Debug("Catch-up Subscription {0} to {1}: subscribing...", SubscriptionName, IsSubscribedToAll ?  "<all>" :  StreamId);
         }
         StreamSubscription storeSubscription;
         if (StreamId == string.Empty)
         {
             storeSubscription = _connection.SubscribeToAll(EnqueuePushedEvent, ServerSubscriptionDropped, _userCredentials);
         }
         else
         {
             storeSubscription = _connection.SubscribeToStream(StreamId, EnqueuePushedEvent, ServerSubscriptionDropped, _userCredentials);
         }
         _subscription = storeSubscription;
         await ReadMissedHistoricEventsAsync().ConfigureAwait(false);
     }
     else
     {
         DropSubscription(SubscriptionDropReason.UserInitiated, null);
     }
 }
コード例 #2
0
 private void EnqueuePushedEvent(StreamSubscription subscription, RecordedEvent e)
 {
     if (Verbose)
     {
         Log.Debug($"Catch-up Subscription {SubscriptionName} to {(IsSubscribedToAll ? "<all>" : StreamId)}: event appeared ({e.EventStreamId}, {e.EventNumber}, {e.EventType}).");
     }
     if (_liveQueue.Count >= MaxPushQueueSize)
     {
         EnqueueSubscriptionDropNotification(SubscriptionDropReason.ProcessingQueueOverflow, null);
         subscription.Unsubscribe();
     }
     _liveQueue.Enqueue(e);
     if (_allowProcessing)
     {
         EnsureProcessingPushQueue();
     }
 }
コード例 #3
0
        internal void DropSubscription(SubscriptionDropReason reason, Exception error)
        {
            if (Interlocked.CompareExchange(ref _isDropped, 1, 0) != 0)
            {
                return;
            }
            if (Verbose)
            {
                Log.Debug("Catch-up Subscription {0} to {1}: dropping subscription, reason: {2} {3}.", SubscriptionName, IsSubscribedToAll ? "<all>" : StreamId, reason, error == null ? string.Empty : error.ToString());
            }
            StreamSubscription subscription = _subscription;

            if (subscription != null)
            {
                subscription.Unsubscribe();
            }
            Action <CatchUpSubscription, SubscriptionDropReason, Exception> subscriptionDropped = _subscriptionDropped;

            if (subscriptionDropped != null)
            {
                subscriptionDropped(this, reason, error);
            }
            _stopped.Set();
        }
コード例 #4
0
 private void ServerSubscriptionDropped(StreamSubscription subscription, SubscriptionDropReason reason, Exception exc)
 {
     EnqueueSubscriptionDropNotification(reason, exc);
 }