Search in sources :

Example 6 with ResponseException

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;
    }
}
Also used : Buffer(org.jboss.narayana.blacktie.jatmibroker.xatmi.Buffer) Response(org.jboss.narayana.blacktie.jatmibroker.xatmi.Response) Codec(org.jboss.narayana.blacktie.jatmibroker.core.transport.Codec) Message(org.jboss.narayana.blacktie.jatmibroker.core.transport.Message) ResponseException(org.jboss.narayana.blacktie.jatmibroker.xatmi.ResponseException) Receiver(org.jboss.narayana.blacktie.jatmibroker.core.transport.Receiver) CodecFactory(org.jboss.narayana.blacktie.jatmibroker.codec.CodecFactory) ConnectionException(org.jboss.narayana.blacktie.jatmibroker.xatmi.ConnectionException)

Aggregations

ConnectionException (org.jboss.narayana.blacktie.jatmibroker.xatmi.ConnectionException)6 ResponseException (org.jboss.narayana.blacktie.jatmibroker.xatmi.ResponseException)6 Buffer (org.jboss.narayana.blacktie.jatmibroker.xatmi.Buffer)3 CodecFactory (org.jboss.narayana.blacktie.jatmibroker.codec.CodecFactory)2 Codec (org.jboss.narayana.blacktie.jatmibroker.core.transport.Codec)2 Message (org.jboss.narayana.blacktie.jatmibroker.core.transport.Message)2 Receiver (org.jboss.narayana.blacktie.jatmibroker.core.transport.Receiver)2 Response (org.jboss.narayana.blacktie.jatmibroker.xatmi.Response)2 ConfigurationException (org.jboss.narayana.blacktie.jatmibroker.core.conf.ConfigurationException)1 Transport (org.jboss.narayana.blacktie.jatmibroker.core.transport.Transport)1 Session (org.jboss.narayana.blacktie.jatmibroker.xatmi.Session)1 X_OCTET (org.jboss.narayana.blacktie.jatmibroker.xatmi.X_OCTET)1