Exemple #1
0
 public Task <AsyncTaskResult> SendAsync(ICommand command)
 {
     try
     {
         return(_sendMessageService.SendMessageAsync(Producer, BuildCommandMessage(command, false), _commandRouteKeyProvider.GetRoutingKey(command), command.Id, null));
     }
     catch (Exception ex)
     {
         return(Task.FromResult(new AsyncTaskResult(AsyncTaskStatus.Failed, ex.Message)));
     }
 }
Exemple #2
0
 public void Send(ICommand command)
 {
     _sendMessageService.SendMessage(_producer, BuildCommandMessage(command), _commandRouteKeyProvider.GetRoutingKey(command));
 }
Exemple #3
0
        public async Task <AsyncTaskResult <CommandResult> > ExecuteAsync(ICommand command, CommandReturnType commandReturnType)
        {
            try
            {
                Ensure.NotNull(_commandResultProcessor, "commandResultProcessor");
                var taskCompletionSource = new TaskCompletionSource <AsyncTaskResult <CommandResult> >();
                _commandResultProcessor.RegisterProcessingCommand(command, commandReturnType, taskCompletionSource);

                var result = await _sendMessageService.SendMessageAsync(_producer, CreateENodeMessage(command, true), _commandRouteKeyProvider.GetRoutingKey(command), command.Id, null).ConfigureAwait(false);

                if (result.Status == AsyncTaskStatus.Success)
                {
                    return(await taskCompletionSource.Task.ConfigureAwait(false));
                }
                _commandResultProcessor.ProcessFailedSendingCommand(command);
                return(new AsyncTaskResult <CommandResult>(result.Status, result.ErrorMessage));
            }
            catch (Exception ex)
            {
                return(new AsyncTaskResult <CommandResult>(AsyncTaskStatus.Failed, ex.Message));
            }
        }