use of com.swiftmq.tools.requestreply.Request in project swiftmq-ce by iitsoftware.
the class InboundReader method dataAvailable.
public void dataAvailable(Connection connection, InputStream inputStream) throws IOException {
dis.setInputStream(inputStream);
Dumpable obj = Dumpalizer.construct(dis, dumpableFactory);
if (traceSpace.enabled)
traceSpace.trace("smqp", "read object: " + obj);
if (obj.getDumpId() != SMQPFactory.DID_KEEPALIVE_REQ) {
if (obj.getDumpId() == SMQPFactory.DID_BULK_REQ) {
SMQPBulkRequest bulkRequest = (SMQPBulkRequest) obj;
for (int i = 0; i < bulkRequest.len; i++) {
Request req = (Request) bulkRequest.dumpables[i];
if (req.getDumpId() != SMQPFactory.DID_KEEPALIVE_REQ)
dispatch(req);
}
} else
dispatch((Request) obj);
}
}
use of com.swiftmq.tools.requestreply.Request in project swiftmq-ce by iitsoftware.
the class InboundReader method dataAvailable.
public void dataAvailable(Connection connection, InputStream inputStream) throws IOException {
dis.setInputStream(inputStream);
Dumpable obj = Dumpalizer.construct(dis, dumpableFactory);
if (traceSpace.enabled)
traceSpace.trace("smqp", "read object: " + obj);
if (obj.getDumpId() != SMQPFactory.DID_KEEPALIVE_REQ) {
if (obj.getDumpId() == SMQPFactory.DID_BULK_REQ) {
SMQPBulkRequest bulkRequest = (SMQPBulkRequest) obj;
for (int i = 0; i < bulkRequest.len; i++) {
Request req = (Request) bulkRequest.dumpables[i];
if (req.getDumpId() != SMQPFactory.DID_KEEPALIVE_REQ)
dispatch(req);
else
resetKeepaliveCount();
}
} else
dispatch((Request) obj);
} else
resetKeepaliveCount();
}
use of com.swiftmq.tools.requestreply.Request in project swiftmq-ce by iitsoftware.
the class DispatcherImpl method visit.
public void visit(ClientRequest event) {
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace(ctx.mgmtSwiftlet.getName(), toString() + "/visit, event: " + event);
try {
dis.reset();
dis.setBuffer(event.getBuffer());
Request request = (Request) Dumpalizer.construct(dis, factory);
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace(ctx.mgmtSwiftlet.getName(), toString() + "/visit, event: " + event + ", request: " + request);
request.accept(this);
} catch (Exception e) {
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace(ctx.mgmtSwiftlet.getName(), toString() + "/visit, event: " + event + ", exception: " + e);
ctx.logSwiftlet.logError(ctx.mgmtSwiftlet.getName(), toString() + "/visit, event: " + event + ", exception: " + e);
valid = false;
}
}
use of com.swiftmq.tools.requestreply.Request in project swiftmq-client by iitsoftware.
the class XAResourceImpl method prepare.
public synchronized int prepare(Xid xid) throws XAException {
if (logWriter != null)
log(toString() + "/prepare, xid=" + xid);
XidImpl sxid = toSwiftMQXid(xid);
XAResPrepareReply reply = null;
try {
int connectionId = session.getSessionImpl().getMyConnection().getConnectionId();
Request request = new XAResPrepareRequest(this, session.getDispatchId(), sxid, false, endRequestInDoubt() ? XARecoverRegistry.getInstance().getRequestList(sxid) : null);
request.setConnectionId(connectionId);
reply = (XAResPrepareReply) session.request(request);
} catch (Exception e) {
XAException ex = new XAException(e.toString());
ex.errorCode = XAException.XAER_RMFAIL;
throw ex;
}
if (!reply.isOk()) {
XAException ex = new XAException(reply.getException().getMessage());
ex.errorCode = reply.getErrorCode();
throw ex;
}
XARecoverRegistry.getInstance().clear(sxid);
return XA_OK;
}
use of com.swiftmq.tools.requestreply.Request in project swiftmq-client by iitsoftware.
the class XAResourceImpl method start.
public synchronized void start(Xid xid, int flags) throws XAException {
if (logWriter != null)
log(toString() + "/start, xid=" + xid + ", flags=" + flags);
XidImpl sxid = toSwiftMQXid(xid);
XAResStartReply reply = null;
int connectionId = session.getSessionImpl().getMyConnection().getConnectionId();
Request request = new XAResStartRequest(this, session.getDispatchId(), sxid, flags, false, null);
request.setConnectionId(connectionId);
try {
reply = (XAResStartReply) session.request(request);
} catch (Exception e) {
XAException ex = new XAException(e.toString());
ex.errorCode = XAException.XAER_RMFAIL;
throw ex;
}
if (!reply.isOk()) {
XAException ex = new XAException(reply.getException().getMessage());
ex.errorCode = reply.getErrorCode();
throw ex;
} else {
XARecoverRegistry.getInstance().addRequest(sxid, request);
try {
session.session.assignLastMessage();
} catch (Exception e) {
XAException ex = new XAException(reply.getException().getMessage());
ex.errorCode = reply.getErrorCode();
throw ex;
}
}
if (completionListener != null)
completionListener.transactionStarted(sxid, session);
}
Aggregations