예제 #1
0
 public void Handle(Envelope <CommandResult> envelope)
 {
     if (_resultManager.SetCommandResult(envelope.MessageId, envelope.Body))
     {
         if (LogManager.Default.IsDebugEnabled)
         {
             LogManager.Default.DebugFormat("command({0}) is completed.", envelope.MessageId);
         }
     }
 }
예제 #2
0
        public Task <ICommandResult> ExecuteAsync(ICommand command, CommandReturnMode returnMode, int timeoutMs)
        {
            var traceId     = ObjectId.GenerateNewId().ToString();
            var commandTask = _resultManger.RegisterProcessingCommand(traceId, command, returnMode, timeoutMs);

            Task.Factory.StartNew(() =>
            {
                try
                {
                    _commandBus.Send(command, new TraceInfo(traceId, ConfigurationSettings.InnerAddress));
                    _resultManger.SetCommandResult(traceId, CommandResult.SentSuccess);
                }
                catch (Exception ex)
                {
                    LogManager.Default.Error("send commands failed. ", ex);
                    _resultManger.SetCommandResult(traceId, CommandResult.SentFailed);
                }
            });

            return(commandTask);
        }