コード例 #1
0
        public void Consume(string eventType, ResolvedEvent e)
        {
            var eventData = new EventData(
                e.Event.EventId,
                e.Event.EventType,
                true,
                e.Event.Data,
                e.Event.Metadata
                );

            using (_logger.TimeOperation("Replicating {EventType} #{EventNumber} from {StreamName}",
                                         e.Event.EventType,
                                         e.Event.EventNumber,
                                         e.Event.EventStreamId))
            {
                _connection.AppendToStreamAsync(e.Event.EventStreamId, e.Event.EventNumber - 1, eventData).GetAwaiter().GetResult();
            }

            if (_settings.ReplicationThrottleInterval.GetValueOrDefault() > 0)
            {
                Thread.Sleep(_settings.ReplicationThrottleInterval.Value);
            }
        }