private void StreamUpdateHandler(StreamUpdateMsg msg) { try { var streamMessage = msg.Data.FromJson <StreamMessage>(); var fixtureDelta = FixtureHelper.GetFixtureDelta(streamMessage); _logger.Info($"{fixtureDelta} stream update arrived"); if (!_fixtureValidation.IsSequenceValid(fixtureDelta, _currentSequence)) { _logger.Warn($"Update for {fixtureDelta} will not be processed because sequence is not valid"); // if snapshot was already processed with higher sequence no need to process this sequence // THIS should never happen!! if (fixtureDelta.Sequence <= _lastSequenceProcessedInSnapshot) { _logger.Warn( $"Stream update {fixtureDelta} will be ignored because snapshot with higher sequence={_lastSequenceProcessedInSnapshot} was already processed"); return; } SuspendAndReprocessSnapshot(); return; } bool hasEpochChanged = fixtureDelta.Epoch != _currentEpoch; if (_fixtureValidation.IsEpochValid(fixtureDelta, _currentEpoch)) { ProcessSnapshot(fixtureDelta, false, hasEpochChanged); _logger.Info($"Update for {fixtureDelta} processed successfully"); } else { ProcessInvalidEpoch(fixtureDelta, hasEpochChanged); } _currentSequence = fixtureDelta.Sequence; _currentEpoch = fixtureDelta.Epoch; } catch (AggregateException ex) { int total = ex.InnerExceptions.Count; int count = 0; foreach (var innerEx in ex.InnerExceptions) { _logger.Error($"Error processing update for {_resource} {innerEx} ({++count}/{total})"); } _erroredException = ex; Become(Errored); } catch (Exception ex) { _logger.Error($"Error processing update {_resource} - exception - {ex}"); _erroredException = ex; Become(Errored); } }