Search in sources :

Example 6 with Response

use of org.jboss.narayana.blacktie.jatmibroker.xatmi.Response in project narayana by jbosstm.

the class TPGetRplyTwoService method tpservice.

public Response tpservice(TPSVCINFO svcinfo) throws ConnectionException, ConfigurationException {
    String response = "test_tpgetrply_TPGETANY_two";
    log.info(response);
    X_OCTET toReturn = (X_OCTET) svcinfo.getConnection().tpalloc("X_OCTET", null);
    toReturn.setByteArray(response.getBytes());
    return new Response(Connection.TPSUCCESS, 0, toReturn, 0);
}
Also used : Response(org.jboss.narayana.blacktie.jatmibroker.xatmi.Response) X_OCTET(org.jboss.narayana.blacktie.jatmibroker.xatmi.X_OCTET)

Example 7 with Response

use of org.jboss.narayana.blacktie.jatmibroker.xatmi.Response in project narayana by jbosstm.

the class TPConversationShortService method tpservice.

public Response tpservice(TPSVCINFO svcinfo) throws ConnectionException, ConfigurationException {
    log.info("testTPConversation_short_service");
    int sendlen = 4;
    X_OCTET sendbuf = (X_OCTET) svcinfo.getConnection().tpalloc("X_OCTET", null);
    sendbuf.setByteArray("hi0".getBytes());
    svcinfo.getSession().tpsend(sendbuf, 0);
    sendbuf.setByteArray("hi1".getBytes());
    return new Response(Connection.TPSUCCESS, 0, sendbuf, 0);
}
Also used : Response(org.jboss.narayana.blacktie.jatmibroker.xatmi.Response) X_OCTET(org.jboss.narayana.blacktie.jatmibroker.xatmi.X_OCTET)

Example 8 with Response

use of org.jboss.narayana.blacktie.jatmibroker.xatmi.Response in project narayana by jbosstm.

the class TPGetRplyOneService method tpservice.

public Response tpservice(TPSVCINFO svcinfo) throws ConnectionException, ConfigurationException {
    String response = "test_tpgetrply_TPGETANY_one";
    log.info(response);
    X_OCTET toReturn = (X_OCTET) svcinfo.getConnection().tpalloc("X_OCTET", null);
    toReturn.setByteArray(response.getBytes());
    try {
        Thread.sleep(3 * 1000);
    } catch (InterruptedException e) {
        log.error("Could not sleep");
    }
    return new Response(Connection.TPSUCCESS, 0, toReturn, 0);
}
Also used : Response(org.jboss.narayana.blacktie.jatmibroker.xatmi.Response) X_OCTET(org.jboss.narayana.blacktie.jatmibroker.xatmi.X_OCTET)

Example 9 with Response

use of org.jboss.narayana.blacktie.jatmibroker.xatmi.Response in project narayana by jbosstm.

the class TTLService method tpservice.

public Response tpservice(TPSVCINFO svcinfo) throws ConnectionException, ConfigurationException {
    log.info("TTLService");
    X_OCTET dptr = (X_OCTET) svcinfo.getBuffer();
    String data = new String(dptr.getByteArray());
    log.info("test_ttl_service get data: " + data);
    int len = 60;
    X_OCTET toReturn = (X_OCTET) svcinfo.getConnection().tpalloc("X_OCTET", null);
    log.info("Data was: " + data);
    if (data.contains("counter")) {
        String counter = String.valueOf(n);
        toReturn.setByteArray(counter.getBytes());
        len = counter.length();
    } else {
        try {
            int timeout = 60;
            log.info("TTLService sleep for " + timeout + " seconds");
            Thread.sleep(timeout * 1000);
            log.info("TTLService slept for " + timeout + " seconds");
            toReturn.setByteArray("test_ttl_service".getBytes());
        } catch (Exception e) {
            log.error("sleep failed with " + e);
        }
        n++;
    }
    return new Response(Connection.TPSUCCESS, 22, toReturn, 0);
}
Also used : Response(org.jboss.narayana.blacktie.jatmibroker.xatmi.Response) X_OCTET(org.jboss.narayana.blacktie.jatmibroker.xatmi.X_OCTET) ConfigurationException(org.jboss.narayana.blacktie.jatmibroker.core.conf.ConfigurationException) ConnectionException(org.jboss.narayana.blacktie.jatmibroker.xatmi.ConnectionException)

Example 10 with Response

use of org.jboss.narayana.blacktie.jatmibroker.xatmi.Response in project narayana by jbosstm.

the class SpecQuickstartOneService method tpservice.

public Response tpservice(TPSVCINFO svcinfo) throws ConnectionException {
    log.info("debit_credit_svc");
    short rval;
    /* extract request typed buffer */
    X_C_TYPE dc_ptr = (X_C_TYPE) svcinfo.getBuffer();
    /*
         * Depending on service name used to invoke this routine, perform either debit or credit work.
         */
    if (!svcinfo.getName().equals("DEBIT")) {
    /*
             * Parse input data and perform debit as part of global transaction.
             */
    } else {
    /*
             * Parse input data and perform credit as part of global transaction.
             */
    }
    // TODO MAKE TWO TESTS
    if (dc_ptr.getInt("failTest") == 0) {
        rval = Connection.TPSUCCESS;
        dc_ptr.setInt("output", TestSpecQuickstartOne.OK);
    } else {
        rval = Connection.TPFAIL;
        /* global transaction will not commit */
        dc_ptr.setInt("output", TestSpecQuickstartOne.NOT_OK);
    }
    /* send reply and return from service routine */
    return new Response(rval, 0, dc_ptr, 0);
}
Also used : Response(org.jboss.narayana.blacktie.jatmibroker.xatmi.Response) X_C_TYPE(org.jboss.narayana.blacktie.jatmibroker.xatmi.X_C_TYPE)

Aggregations

Response (org.jboss.narayana.blacktie.jatmibroker.xatmi.Response)35 X_OCTET (org.jboss.narayana.blacktie.jatmibroker.xatmi.X_OCTET)29 ConnectionException (org.jboss.narayana.blacktie.jatmibroker.xatmi.ConnectionException)12 ConfigurationException (org.jboss.narayana.blacktie.jatmibroker.core.conf.ConfigurationException)8 StringTokenizer (java.util.StringTokenizer)3 X_C_TYPE (org.jboss.narayana.blacktie.jatmibroker.xatmi.X_C_TYPE)3 IOException (java.io.IOException)2 List (java.util.List)2 Buffer (org.jboss.narayana.blacktie.jatmibroker.xatmi.Buffer)2 ResponseException (org.jboss.narayana.blacktie.jatmibroker.xatmi.ResponseException)2 X_COMMON (org.jboss.narayana.blacktie.jatmibroker.xatmi.X_COMMON)2 StringReader (java.io.StringReader)1 UnknownHostException (java.net.UnknownHostException)1 ArrayList (java.util.ArrayList)1 DocumentBuilder (javax.xml.parsers.DocumentBuilder)1 DocumentBuilderFactory (javax.xml.parsers.DocumentBuilderFactory)1 CodecFactory (org.jboss.narayana.blacktie.jatmibroker.codec.CodecFactory)1 Codec (org.jboss.narayana.blacktie.jatmibroker.core.transport.Codec)1 Message (org.jboss.narayana.blacktie.jatmibroker.core.transport.Message)1 Receiver (org.jboss.narayana.blacktie.jatmibroker.core.transport.Receiver)1