reorganize the connection response code to only pump once all state is
process.
This commit is contained in:
Timothy Bish 2015-02-25 10:17:06 -05:00
parent 0142c4dc89
commit f988ca6e49
1 changed files with 18 additions and 14 deletions

View File

@ -530,24 +530,28 @@ class AmqpProtocolConverter implements IAmqpProtocolConverter {
sendToActiveMQ(connectionInfo, new ResponseHandler() {
@Override
public void onResponse(IAmqpProtocolConverter converter, Response response) throws IOException {
protonConnection.open();
pumpProtonToSocket();
Throwable exception = null;
try {
protonConnection.open();
if (response.isException()) {
Throwable exception = ((ExceptionResponse) response).getException();
if (exception instanceof SecurityException) {
protonConnection.setCondition(new ErrorCondition(AmqpError.UNAUTHORIZED_ACCESS, exception.getMessage()));
} else if (exception instanceof InvalidClientIDException) {
protonConnection.setCondition(new ErrorCondition(AmqpError.INVALID_FIELD, exception.getMessage()));
} else {
protonConnection.setCondition(new ErrorCondition(AmqpError.ILLEGAL_STATE, exception.getMessage()));
if (response.isException()) {
exception = ((ExceptionResponse) response).getException();
if (exception instanceof SecurityException) {
protonConnection.setCondition(new ErrorCondition(AmqpError.UNAUTHORIZED_ACCESS, exception.getMessage()));
} else if (exception instanceof InvalidClientIDException) {
protonConnection.setCondition(new ErrorCondition(AmqpError.INVALID_FIELD, exception.getMessage()));
} else {
protonConnection.setCondition(new ErrorCondition(AmqpError.ILLEGAL_STATE, exception.getMessage()));
}
protonConnection.close();
}
protonConnection.close();
} finally {
pumpProtonToSocket();
amqpTransport.onException(IOExceptionSupport.create(exception));
return;
}
if (response.isException()) {
amqpTransport.onException(IOExceptionSupport.create(exception));
}
}
}
});
}