private async Task TryRunHandler <TEvent>(IEventHandlerAsync <TEvent> handler, TEvent @event)
        {
            try
            {
                if (!await handler.ShouldHandleAsync(@event).ConfigureAwait(false))
                {
                    return;
                }

                await handler.HandleAsync(@event).ConfigureAwait(false);
            }
            catch (Exception exception)
            {
                await TryReportError(exception, handler, @event).ConfigureAwait(false);
            }
        }
Exemple #2
0
 public Task HandleAsync(TEvent @event) => _eventHandler.HandleAsync(@event);
Exemple #3
0
 public static ISubscription WithEventHandlerAsync <TEvent>(this IBusClient bus,
                                                            IEventHandlerAsync <TEvent> handler, string exchangeName = null, string routingKey = null) where TEvent : IEvent
 => bus.SubscribeAsync <TEvent>(async(msg, context) => await handler.HandleAsync(msg),
                                cfg => cfg.WithExchange(e => e.WithName(exchangeName)).WithRoutingKey(routingKey));