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); } } }
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); }