private void DeliverEvent(EventRecord @event, EventRecord positionEvent, float progress) { _deliveredEvents++; string streamId = positionEvent.EventStreamId; int fromPosition = _fromPositions.Streams[streamId]; if (positionEvent.EventNumber != fromPosition) { throw new InvalidOperationException( string.Format( "Event number {0} was expected in the stream {1}, but event number {2} was received", fromPosition, streamId, positionEvent.EventNumber)); } _fromPositions = _fromPositions.UpdateStreamPosition(streamId, positionEvent.EventNumber + 1); var resolvedLinkTo = streamId != @event.EventStreamId || positionEvent.EventNumber != @event.EventNumber; _publisher.Publish( //TODO: publish both link and event data new ReaderSubscriptionMessage.CommittedEventDistributed( EventReaderCorrelationId, new ResolvedEvent( streamId, positionEvent.EventNumber, @event.EventStreamId, @event.EventNumber, resolvedLinkTo, new TFPos(-1, positionEvent.LogPosition), new TFPos(-1, @event.LogPosition), @event.EventId, @event.EventType, (@event.Flags & PrepareFlags.IsJson) != 0, @event.Data, @event.Metadata, @event == positionEvent ? null : positionEvent.Metadata, positionEvent.TimeStamp), _stopOnEof ? (long?)null : positionEvent.LogPosition, progress, source: this.GetType())); }
private void DeliverEvent(EventStore.Core.Data.ResolvedEvent pair, float progress) { _deliveredEvents++; var positionEvent = pair.OriginalEvent; string streamId = positionEvent.EventStreamId; long fromPosition = _fromPositions.Streams[streamId]; //if events have been deleted from the beginning of the stream, start from the first event we find if (fromPosition == 0 && positionEvent.EventNumber > 0) { fromPosition = positionEvent.EventNumber; } if (positionEvent.EventNumber != fromPosition) { string reason = string.Format( "Event number {0} was expected in the stream {1}, but event number {2} was received. This may happen if events have been deleted from the beginning of your stream, please reset your projection.", fromPosition, streamId, positionEvent.EventNumber); _publisher.Publish(new ReaderSubscriptionMessage.Faulted(EventReaderCorrelationId, reason, this.GetType())); throw new InvalidOperationException(reason); } _fromPositions = _fromPositions.UpdateStreamPosition(streamId, positionEvent.EventNumber + 1); _publisher.Publish( //TODO: publish both link and event data new ReaderSubscriptionMessage.CommittedEventDistributed( EventReaderCorrelationId, new ResolvedEvent(pair, null), _stopOnEof ? (long?)null : positionEvent.LogPosition, progress, source: this.GetType())); }
public override CheckpointTag MakeCheckpointTag(CheckpointTag previous, ProjectionCoreServiceMessage.CommittedEventDistributed comittedEvent) { if (!_streams.Contains(comittedEvent.PositionStreamId)) { throw new InvalidOperationException(string.Format("Invalid stream '{0}'", comittedEvent.EventStreamId)); } return(previous.UpdateStreamPosition(comittedEvent.PositionStreamId, comittedEvent.PositionSequenceNumber)); }
public override CheckpointTag MakeCheckpointTag( CheckpointTag previous, ReaderSubscriptionMessage.CommittedEventDistributed committedEvent) { if (previous.Phase != Phase) { throw new ArgumentException( string.Format("Invalid checkpoint tag phase. Expected: {0} Was: {1}", Phase, previous.Phase)); } if (!_streams.Contains(committedEvent.Data.PositionStreamId)) { throw new InvalidOperationException( string.Format("Invalid stream '{0}'", committedEvent.Data.EventStreamId)); } return(previous.UpdateStreamPosition( committedEvent.Data.PositionStreamId, committedEvent.Data.PositionSequenceNumber)); }
private void DeliverEvent(EventStore.Core.Data.ResolvedEvent pair, float progress) { _deliveredEvents++; var positionEvent = pair.OriginalEvent; string streamId = positionEvent.EventStreamId; long fromPosition = _fromPositions.Streams[streamId]; if (positionEvent.EventNumber != fromPosition) { throw new InvalidOperationException( string.Format( "Event number {0} was expected in the stream {1}, but event number {2} was received", fromPosition, streamId, positionEvent.EventNumber)); } _fromPositions = _fromPositions.UpdateStreamPosition(streamId, positionEvent.EventNumber + 1); _publisher.Publish( //TODO: publish both link and event data new ReaderSubscriptionMessage.CommittedEventDistributed( EventReaderCorrelationId, new ResolvedEvent(pair, null), _stopOnEof ? (long?)null : positionEvent.LogPosition, progress, source: this.GetType())); }
private void DeliverEvent(EventRecord @event, EventRecord positionEvent, float progress) { string streamId = positionEvent.EventStreamId; int fromPosition = _fromPositions.Streams[streamId]; if (positionEvent.EventNumber != fromPosition) { throw new InvalidOperationException( string.Format( "Event number {0} was expected in the stream {1}, but event number {2} was received", fromPosition, streamId, positionEvent.EventNumber)); } _fromPositions = _fromPositions.UpdateStreamPosition(streamId, positionEvent.EventNumber + 1); var resolvedLinkTo = streamId != @event.EventStreamId || positionEvent.EventNumber != @event.EventNumber; _publisher.Publish( //TODO: publish both link and event data new ProjectionCoreServiceMessage.CommittedEventDistributed( _distibutionPointCorrelationId, default(EventPosition), streamId, positionEvent.EventNumber, @event.EventStreamId, @event.EventNumber, resolvedLinkTo, new Event(@event.EventId, @event.EventType, false, @event.Data, @event.Metadata), positionEvent.LogPosition, progress)); }