private void SubscriptionDropped(EventStorePersistentSubscriptionBase sub, SubscriptionDropReason reason, Exception ex) { Live = false; Logger.Write(LogLevel.Info, () => $"Disconnected from subscription. Reason: {reason} Exception: {ex}"); // Todo: is it possible to ACK an event from a reconnection? //if (_toAck.Any()) // throw new InvalidOperationException( // $"Eventstore subscription dropped and we need to ACK {_toAck.Count} more events"); // Need to clear ReadyEvents of events delivered but not processed before disconnect ResolvedEvent e; while (!_waitingEvents.IsEmpty) { Queued.Decrement(Id); QueuedEvents.Decrement(Id); _waitingEvents.TryDequeue(out e); } if (reason == SubscriptionDropReason.UserInitiated) { return; } // Task.Run(Connect, _token); }
public void Decrement() { counter.Decrement(); }