protected override void OnCommand(ITransport sender, Command command) { if (command is Response) { Response response = (Response)command; FutureResponse future = (FutureResponse)requestMap[response.CorrelationId]; if (future != null) { if (response is ExceptionResponse) { ExceptionResponse er = (ExceptionResponse)response; BrokerError brokerError = er.Exception; BrokerException exception = new BrokerException(brokerError); this.exceptionHandler(this, exception); } future.Response = response; } else { if (command is ShutdownInfo) { // lets shutdown this.commandHandler(sender, command); } else { Tracer.Error("Unknown response ID: " + response.CommandId + " for response: " + response); } } } else { this.commandHandler(sender, command); } }
public override FutureResponse AsyncRequest(Command command) { command.CommandId = GetNextCommandId(); command.ResponseRequired = true; FutureResponse future = new FutureResponse(); requestMap[command.CommandId] = future; next.Oneway(command); return(future); }
public override FutureResponse AsyncRequest(Command command) { command.CommandId = GetNextCommandId(); command.ResponseRequired = true; FutureResponse future = new FutureResponse(); requestMap[command.CommandId] = future; next.Oneway(command); return future; }
public override Response Request(Command command) { FutureResponse future = AsyncRequest(command); Response response = future.Response; if (response != null && response is ExceptionResponse) { ExceptionResponse er = (ExceptionResponse)response; BrokerError brokerError = er.Exception; if (brokerError == null) { throw new BrokerException(); } else { throw new BrokerException(brokerError); } } return(response); }