Esempio n. 1
0
        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);
            }
        }
Esempio n. 2
0
 public Task HandleAsync(TEvent @event) => _eventHandler.HandleAsync(@event);
Esempio n. 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));