Esempio n. 1
0
        /// <inheritdoc />
        public async Task <IExecutionResult> Handle(
            CommandRequest <TCommand> request,
            CancellationToken cancellationToken,
            RequestHandlerDelegate <IExecutionResult> next)
        {
            var result = await next();

            if (!result.Success)
            {
                await reportBus.PublishAsync(new OperationFailedSignal(request.Command, (FailedResult)result));

                return(result);
            }

            if (result is IntegrationEventExecutionResult e)
            {
                // Publish domain event.
                await eventBus.PublishAsync(e.Event);

                // Mark domain event as published.
                await integrationEventStore.MarkAsPublishedAsync(e.Event);
            }

            await reportBus.PublishAsync(new OperationCompletedSignal(request.Command));

            return(result);
        }
Esempio n. 2
0
        /// <inheritdoc />
        public async Task Handle(QueryModelChangedNotification notification, CancellationToken cancellationToken)
        {
            if (notification.IsReplay || notification.IsPrivate)
            {
                logger.LogDebug(
                    "Query model '{QueryModelType}' of id '{QueryModelId}' signal is private or it's a replay and it wouldn't be published.",
                    notification.Signal.QueryModelType,
                    notification.Signal.QueryModelId);

                return;
            }

            await reportBus.PublishAsync(notification.Signal);
        }