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)); }
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()); } }