Esempio n. 1
0
        private void HandleEvent(EventStoreCatchUpSubscription arg1, ResolvedEvent arg2)
        {
            var @event = SerializationUtils.DeserializeEvent(arg2.OriginalEvent);

            if (@event == null)
            {
                return;
            }
            var eventType = @event.GetType();

            if (@event is IMessage)
            {
                if (@event is IEvent)
                {
                    _domainEntry.Publish(@event as IEvent);
                }
                if (@event is ICommand)
                {
                    _domainEntry.Send(@event as ICommand);
                }
            }
            _latestPosition = arg2.OriginalPosition;

            if (_latestPosition.HasValue && _domainEntry.CanHandle(eventType))
            {
                _checkpointRepository.Save(_latestPosition.Value);
            }
        }
Esempio n. 2
0
        private Checkpoint GetCheckpoint(Shard shard)
        {
            _logger.LogInformation("Loading checkpoint for shard: {0}", shard.ShardId);
            Checkpoint checkPoint = _checkpointRepository.Load(shard.ShardId, _streamName, _readerName);

            if (checkPoint == null)
            {
                _logger.LogWarning("No checkpoint for shard: {0}. Creating one.", shard.ShardId);
                checkPoint = new Checkpoint(shard, _streamName, _readerName);
                _checkpointRepository.Save(checkPoint);
            }

            return(checkPoint);
        }