use of org.jboss.narayana.blacktie.jatmibroker.xatmi.ResponseException in project narayana by jbosstm.
the class ConnectionImpl method receive.
/**
* Retrieve a response.
*
* @param cd
* The connection descriptor
* @param flags
* The flags to use
* @return The response
* @throws ConnectionException
* If the response cannot be retrieved.
* @throws ConfigurationException
*/
private Response receive(int cd, int flags) throws ConnectionException, ConfigurationException {
log.debug("receive: " + cd);
Receiver endpoint = temporaryQueues.get(cd);
if (endpoint == null) {
throw new ConnectionException(ConnectionImpl.TPEBADDESC, "Session does not exist: " + cd);
}
Message message = endpoint.receive(flags);
Buffer buffer = null;
if (message.type != null && !message.type.equals("")) {
CodecFactory factory = new CodecFactory(this);
String coding_type = properties.getProperty("blacktie." + message.serviceName + ".coding_type");
Codec codec = factory.getCodec(coding_type);
buffer = codec.decode(message.type, message.subtype, message.data, message.len);
// buffer = tpalloc(message.type, message.subtype, message.len);
// buffer.deserialize(message.data);
}
if (message.rval == ConnectionImpl.TPFAIL) {
if (message.rcode == ConnectionImpl.TPESVCERR) {
throw new ResponseException(ConnectionImpl.TPESVCERR, "Got an error back from the remote service", -1, message.rcode, buffer);
}
throw new ResponseException(ConnectionImpl.TPESVCFAIL, "Got a fail back from the remote service", -1, message.rcode, buffer);
} else {
Response response = new Response(cd, message.rval, message.rcode, buffer, message.flags);
log.debug("received returned a response? " + (response == null ? "false" : "true"));
return response;
}
}
Aggregations