private void NotifySubscriptionDropped(SubscriptionDroppedReason reason, Exception exception = null) { if (_notificationRaised.CompareExchange(true, false)) { return; } try { s_logger.InfoException($"Subscription dropped {Name}/{StreamId}. Reason: {reason}", exception); _subscriptionDropped.Invoke(this, reason, exception); } catch (Exception ex) { s_logger.ErrorException( $"Error notifying subscriber that subscription has been dropped ({Name}/{StreamId}).", ex); } }
protected override async Task <bool> DoFetch() { var allEventsPage = await ReadOnlyEventStore .ReadAllForwards( _nextCheckpoint, PageSize, IsDisposed) .NotOnCapturedContext(); bool isEnd = allEventsPage.IsEnd; foreach (var streamEvent in allEventsPage.StreamEvents) { if (IsDisposed.IsCancellationRequested) { return(true); } try { await StreamEventReceived(streamEvent).NotOnCapturedContext(); LastCheckpoint = streamEvent.Checkpoint; _nextCheckpoint = streamEvent.Checkpoint + 1; } catch (Exception ex) { try { SubscriptionDropped.Invoke(ex.Message, ex); } catch { //TODO logging } finally { Dispose(); } } } return(isEnd); }
protected override async Task <bool> DoFetch() { var allMessagesPage = await ReadonlyStreamStore .ReadAllForwards( _nextPosition, PageSize, IsDisposed) .NotOnCapturedContext(); bool isEnd = allMessagesPage.IsEnd; foreach (var streamMessage in allMessagesPage.Messages) { if (IsDisposed.IsCancellationRequested) { return(true); } try { await StreamMessageReceived(streamMessage).NotOnCapturedContext(); LastPosition = streamMessage.Position; _nextPosition = streamMessage.Position + 1; } catch (Exception ex) { try { SubscriptionDropped.Invoke(ex.Message, ex); } catch { //TODO logging } finally { Dispose(); } } } return(isEnd); }
protected override async Task <bool> DoFetch() { var streamMessagesPage = await ReadonlyStreamStore .ReadStreamForwards( _streamId, _nextVersion, PageSize, IsDisposed) .NotOnCapturedContext(); bool isEnd = streamMessagesPage.IsEndOfStream; foreach (var message in streamMessagesPage.Messages) { if (IsDisposed.IsCancellationRequested) { return(true); } _nextVersion = message.StreamVersion + 1; _lastVersion = message.StreamVersion; try { await StreamMessageReceived(message).NotOnCapturedContext(); } catch (Exception ex) { try { SubscriptionDropped.Invoke(ex.Message, ex); } catch (Exception ex2) { // Need to log this } finally { Dispose(); } } } return(isEnd); }