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);
}
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);
}
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);
}
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);
}
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);
}
Aggregations