예제 #1
0
        public override FutureResponse AsyncRequest(ICommand command)
        {
            var commandId = GetNextCommandId();

            command.CommandId        = commandId;
            command.ResponseRequired = true;
            var future = new FutureResponse();

            var priorError = _error;

            if (priorError == null)
            {
                _requestMap.AddOrUpdate(commandId, future, (k, v) => future);
            }

            if (priorError != null)
            {
                var brError = new BrokerError {
                    Message = priorError.Message
                };
                var response = new ExceptionResponse {
                    Exception = brError
                };
                future.Response = response;
                throw priorError;
            }

            Next.Oneway(command);

            return(future);
        }
예제 #2
0
        public override FutureResponse AsyncRequest(ICommand command)
        {
            var commandId = GetNextCommandId();

            command.CommandId        = commandId;
            command.ResponseRequired = true;
            var       future = new FutureResponse();
            Exception priorError;

            lock (_requestMap.SyncRoot)
            {
                priorError = _error;
                if (priorError == null)
                {
                    _requestMap[commandId] = future;
                }
            }

            if (priorError != null)
            {
                var brError = new BrokerError {
                    Message = priorError.Message
                };
                var response = new ExceptionResponse {
                    Exception = brError
                };
                future.Response = response;
                throw priorError;
            }

            Next.Oneway(command);

            return(future);
        }