private void StopSubscriptionEpoch()
        {
            if (_catchUpSubscription == null)
            {
                return;
            }

            try
            {
                _subscriptionEpochStopping = true;

                Log.Information("Stopping catch all subscription epoch {Name}! Waiting for queued events to process.", SubscriptionName);

                var stopSubscriptionWatch = Stopwatch.StartNew();

                _catchUpSubscription.Stop(TimeSpan.FromMilliseconds(_settings.StopSubscriptionTimeout));

                Log.Information("Subscription epoch {Name} stopped after {Elapsed} ms!", SubscriptionName, stopSubscriptionWatch.ElapsedMilliseconds);
            }
            catch (TimeoutException e)
            {
                Log.Error(e, "Could not stop the subscription epoch {Name} after {Timeout} ms!", SubscriptionName, _settings.StopSubscriptionTimeout);
            }
            finally
            {
                _subscriptionEpochStopping = false;
            }
        }
        public Task <bool> Stop()
        {
            _destinationConnection.ErrorOccurred        -= DestinationConnection_ErrorOccurred;
            _destinationConnection.Disconnected         -= DestinationConnection_Disconnected;
            _destinationConnection.AuthenticationFailed += DestinationConnection_AuthenticationFailed;
            _destinationConnection.Connected            -= DestinationConnection_Connected;
            _destinationConnection.Reconnecting         -= _destinationConnection_Reconnecting;

            _originConnection.ErrorOccurred        -= OriginConnection_ErrorOccurred;
            _originConnection.Disconnected         -= OriginConnection_Disconnected;
            _originConnection.AuthenticationFailed -= OriginConnection_AuthenticationFailed;
            _originConnection.Connected            -= OriginConnection_Connected;
            _originConnection.Reconnecting         -= _originConnection_Reconnecting;

            _processor.Stop();
            _allCatchUpSubscription?.Stop();
            _destinationConnection?.Close();
            _originConnection?.Close();
            _positionRepository.Stop();
            _timerForStats.Stop();
            _totalProcessedMessagesCurrent = 0;
            _started = false;
            _logger.Info($"{Name} stopped");
            return(Task.FromResult(true));
        }
 private void Processor_Elapsed(object sender, ElapsedEventArgs e)
 {
     if (_internalBuffer.IsEmpty)
     {
         return;
     }
     try
     {
         _processor.Stop();
         _allCatchUpSubscription.Stop();
         var watch           = System.Diagnostics.Stopwatch.StartNew();
         var eventsToProcess = _internalBuffer.Count;
         var oldPerfSettings = _perfTunedSettings.Clone() as PerfTuneSettings;
         ProcessQueueAndWaitAll();
         watch.Stop();
         var elapsedMs = watch.ElapsedMilliseconds;
         _logger.Debug($"{Name} Replicated '{eventsToProcess}' events in {elapsedMs}ms");
         _perfTunedSettings = _replicaHelper.OptimizeSettings(elapsedMs, _perfTunedSettings);
         if (!_perfTunedSettings.Equals(oldPerfSettings))
         {
             _logger.Debug($"{Name} Old PerfSettings: {oldPerfSettings}");
             _logger.Debug($"{Name} New PerfSettings: {_perfTunedSettings}");
         }
         Subscribe(_lastPosition);
         _processor.Start();
     }
     catch (Exception exception)
     {
         _logger.Error($"Error while Processor_Elapsed: {exception.GetBaseException().Message}");
         Stop();
         Start();
     }
 }
Example #4
0
 public void StopDispatching()
 {
     _stopRequested = true;
     if (_subscription != null)
     {
         _subscription.Stop(TimeSpan.FromSeconds(2));
     }
 }
        private void Subscribe()
        {
            if (_currentConnection == null)
            {
                return;
            }

            _subscription?.Stop();

            _subscription = _currentConnection.SubscribeToAllFrom(
                _lastPosition,
                CatchUpSubscriptionSettings.Default,
                EventAppeared,
                LiveProcessingStarted,
                SubscriptionDropped
                );
        }
 private void Stop()
 {
     _subscription.Stop();
     if (_setLastCheckpoint != null)
     {
         _setLastCheckpoint(_subscription.LastProcessedPosition);
     }
 }
        protected override void OnDisconnected(object sender, ClientConnectionEventArgs clientConnectionEventArgs)
        {
            _catchUpSubscription?.Stop();

            if (!_subscriptionTerminatedRequested)
            {
                Log.Information("Subscription {Name} with epoch {Epoch}, disconnected from EventStore. Waiting for reconnect to start a new epoch.", _subscriptionName, _subscriptionEpoch);
            }
        }
Example #8
0
 public void Stop()
 {
     _subscription?.Stop();
 }
 public void Stop() => _subscription.Stop();
Example #10
0
 public Task StopAsync(CancellationToken cancellationToken)
 {
     _subscription.Stop();
     return(Task.CompletedTask);
 }
 public void Stop() => subscription?.Stop();