public virtual Task <bool> PublishAsync <TEvent>(TEvent @event) where TEvent : class, IEventBase { var queueName = _options.EventQueueNameResolver.Invoke(@event.GetType()) ?? "events"; return(_eventQueue.EnqueueAsync(queueName, @event)); }
public async Task <CommandResult> Handle( IngestEventCommand command, CancellationToken cancellationToken) { _logger.LogCommandHandling(command.ToString()); if (cancellationToken .IsCancellationRequested) { _logger.LogCommandCancelling(command.ToString()); return(new CommandResult( command.Id, CommandResultType.Aborted)); } var @event = command.Event; _logger.LogIngestingEventOfType(@event.EventType); try { await _eventQueue.EnqueueAsync( @event, cancellationToken); } catch (Exception ex) { _logger.LogCommandFailed( command.ToString(), ex); return(new CommandResult( command.Id, CommandResultType.Failure)); } _logger.LogCommandHandled(command.ToString()); return(new CommandResult(command.Id)); }
public static Task <bool> EnqueueAsync <TEvent>(this IEventQueue eventQueue, TEvent @event) where TEvent : class, IEventBase { return(eventQueue.EnqueueAsync(DefaultQueueName, @event)); }