private async Task PublishEvents(IEnumerable <IEvent> events)
 {
     foreach (var @event in events)
     {
         var commandEvent = GenericEventActivator.CreateCommandEvent(@event);
         await _mediator.Publish(commandEvent);
     }
 }
Beispiel #2
0
        public async Task HandleReadEvents(EventStoreCatchUpSubscription subscription, ResolvedEvent resolvedEvent)
        {
            if (resolvedEvent.OriginalPosition == null)
            {
                throw new ArgumentNullException(nameof(resolvedEvent.OriginalPosition));
            }

            var @event = resolvedEvent.DeserializeEvent();

            if (@event != null)
            {
                var queryEvent = GenericEventActivator.CreateQueryEvent(@event);
                await _mediator.Publish(queryEvent);
                await UpdatePosition(resolvedEvent.OriginalPosition.Value);
            }
        }