Exemplo n.º 1
0
 public Task SubscribeToAllAsync(Func <IEvent, Task> handler, CancellationToken cancellationToken = default)
 {
     return(_messageBusSubscriber.SubscribeAsync(async envelope =>
     {
         using (CorrelationManager.NewCorrelationId(envelope.GetCorrelationId()))
         {
             await handler(envelope.Payload);
         }
     }, cancellationToken, _messagingTopicResolver.ResolveTopicName(), _subscriberOptions));
 }
Exemplo n.º 2
0
        public async Task AppendEventsToStreamAsync(string stream, IEnumerable <IEvent> events, int?expectedVersion,
                                                    CancellationToken cancellationToken = default)
        {
            var eventList = events.ToList();
            await _innerEventStore.AppendEventsToStreamAsync(stream, eventList, expectedVersion, cancellationToken);

            foreach (var @event in eventList)
            {
                await _messageBusPublisher.PublishAsync(@event, cancellationToken, null, _messagingTopicResolver.ResolveTopicName());
            }
        }