private void LoadProjectionListCompleted( ClientMessage.ReadEventsBackwardsCompleted completed, int requestedFrom) { if (completed.Result == RangeReadResult.Success && completed.Events.Length > 0) { if (completed.NextEventNumber != -1) { BeginLoadProjectionList(@from: completed.NextEventNumber); } foreach (var @event in completed.Events.Where(v => v.EventType == "ProjectionCreated")) { var projectionName = Encoding.UTF8.GetString(@event.Data); if (_projections.ContainsKey(projectionName)) { //TODO: log this event as it should not happen continue; // ignore older attempts to create a projection } var managedProjection = CreateManagedProjectionInstance(projectionName); managedProjection.InitializeExisting(projectionName); } } else { if (requestedFrom == -1) { _logger.Info( "Projection manager is initializing from the empty {0} stream", completed.EventStreamId); CreatePredefinedProjections(); } } }
private void LoadCompleted(ClientMessage.ReadEventsBackwardsCompleted completed) { if (completed.Result == RangeReadResult.Success && completed.Events.Length == 1) { byte[] state = completed.Events[0].Data; LoadPersistedState(state.ParseJson <PersistedState>()); //TODO: encapsulate this into managed projection _state = ManagedProjectionState.Stopped; StartIfEnabled(); return; } _state = ManagedProjectionState.Creating; _logger.Info( "Projection manager did not find any projection configuration records in the {0} stream. Projection stays in CREATING state", completed.EventStreamId); }
public void Handle(ClientMessage.ReadEventsBackwardsCompleted message) { if (!_awaitingListEventsCompleted) { throw new InvalidOperationException("ReadEventsBackwards has not been requested"); } _awaitingListEventsCompleted = false; if (message.Events.Length == 0) { _lastCommittedMetadata = null; _lastKnownEventNumber = ExpectedVersion.NoStream; SubmitWriteEvents(); } else { var projectionStateMetadata = message.Events[0].Metadata.ParseJson <CheckpointTag>(); _lastCommittedMetadata = projectionStateMetadata; _lastKnownEventNumber = message.Events[0].EventNumber; SubmitWriteEventsInRecovery(); } }
public void Handle(ClientMessage.ReadEventsBackwardsCompleted message) { _readDispatcher.Handle(message); }