private void CompleteCommandWithResult(ProcessingCommand processingCommand, CommandResult commandResult)
 {
     try
     {
         processingCommand.Complete(commandResult);
     }
     catch (Exception ex)
     {
         _logger.Error(string.Format("Failed to complete command, commandId: {0}, aggregateRootId: {1}", processingCommand.Message.Id, processingCommand.Message.AggregateRootId), ex);
     }
 }
Example #2
0
 private void PublishDomainEventAsync(ProcessingCommand processingCommand, DomainEventStreamMessage eventStream, int retryTimes)
 {
     _ioHelper.TryAsyncActionRecursively<AsyncTaskResult>("PublishDomainEventAsync",
     () => _domainEventPublisher.PublishAsync(eventStream),
     currentRetryTimes => PublishDomainEventAsync(processingCommand, eventStream, currentRetryTimes),
     result =>
     {
         if (_logger.IsDebugEnabled)
         {
             _logger.DebugFormat("Publish domain events success, {0}", eventStream);
         }
         var commandHandleResult = processingCommand.CommandExecuteContext.GetResult();
         processingCommand.Complete(new CommandResult(CommandStatus.Success, processingCommand.Message.Id, eventStream.AggregateRootId, commandHandleResult, typeof(string).FullName));
     },
     () => string.Format("[eventStream:{0}]", eventStream),
     errorMessage => processingCommand.Complete(new CommandResult(CommandStatus.Failed, processingCommand.Message.Id, eventStream.AggregateRootId, errorMessage ?? "Publish domain event async failed.", typeof(string).FullName)),
     retryTimes);
 }
Example #3
0
 private void PublishDomainEventAsync(ProcessingCommand processingCommand, DomainEventStreamMessage eventStream, int retryTimes)
 {
     _ioHelper.TryAsyncActionRecursively<AsyncTaskResult>("PublishDomainEventAsync",
     () => _domainEventPublisher.PublishAsync(eventStream),
     currentRetryTimes => PublishDomainEventAsync(processingCommand, eventStream, currentRetryTimes),
     result =>
     {
         _logger.DebugFormat("Publish domain events success, {0}", eventStream);
         processingCommand.Complete(new CommandResult(CommandStatus.Success, processingCommand.Message.Id, eventStream.AggregateRootId, null, null));
     },
     () => string.Format("[eventStream:{0}]", eventStream),
     errorMessage => processingCommand.Complete(new CommandResult(CommandStatus.Failed, processingCommand.Message.Id, eventStream.AggregateRootId, null, errorMessage ?? "Publish domain event async failed.")),
     retryTimes);
 }
Example #4
0
 private void CompleteMessageWithResult(ProcessingCommand processingCommand, CommandResult commandResult)
 {
     try
     {
         processingCommand.Complete(commandResult);
     }
     catch (Exception ex)
     {
         _logger.Error(string.Format("Failed to complete command, commandId: {0}, aggregateRootId: {1}", processingCommand.Message.Id, processingCommand.Message.AggregateRootId), ex);
     }
 }