/// <inheritdoc /> public async Task PublishAsync <TEvent>(TEvent @event) where TEvent : IEvent { if (@event == null) { throw new ArgumentNullException(nameof(@event)); } var handlers = _resolver.ResolveAll <IEventHandlerAsync <TEvent> >(); foreach (var handler in handlers) { await handler.HandleAsync(@event); } if (@event is IBusMessage message) { await _busMessageDispatcher.DispatchAsync(message); } }
/// <inheritdoc /> public void Publish <TEvent>(TEvent @event) where TEvent : IEvent { if (@event == null) { throw new ArgumentNullException(nameof(@event)); } var handlers = _resolver.ResolveAll <IEventHandler <TEvent> >(); foreach (var handler in handlers) { handler.Handle(@event); } if (@event is IBusMessage message) { _busMessageDispatcher.DispatchAsync(message).GetAwaiter().GetResult(); } }
public async Task PublishAsync <TEvent>(TEvent @event) where TEvent : IEvent { if (@event == null) { throw new ArgumentNullException(nameof(@event)); } _userContext = @event.UserContext; //TODO there is a probability to have multiple handlers var handler = _handlerResolver.ResolveHandler(@event, typeof(IEventHandlerAsync <>)); //TODO inmemory handler is not triggering if (handler != null) { await handler.AsDynamic().HandleAsync(@event); } if (@event is IBusTopicMessage message) { await _busMessageDispatcher.DispatchAsync(message); } }
/// <inheritdoc /> public Task DispatchBusMessageAsync <TMessage>(TMessage message) where TMessage : IBusMessage { return(_busMessageDispatcher.DispatchAsync(message)); }
public Task SendBusMessageAsync <TMessage>(TMessage message) where TMessage : IMessage { SetUserContextWithMessage(message); return(_busMessageDispatcher.DispatchAsync(message)); }