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) {
e.printStackTrace();
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-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_KEEP_ALIVE_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_KEEP_ALIVE_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_KEEP_ALIVE_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_KEEP_ALIVE_REQ)
dispatch(req);
}
} else
dispatch((Request) obj);
}
}
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());
if (reply.getErrorCode() != 0)
ex.errorCode = reply.getErrorCode();
else
ex.errorCode = XAException.XAER_RMFAIL;
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 rollback.
public synchronized void rollback(Xid xid) throws XAException {
if (logWriter != null)
log(toString() + "/rollback, xid=" + xid);
XidImpl sxid = toSwiftMQXid(xid);
xidMapping.remove(xid);
XAResRollbackReply reply = null;
try {
int connectionId = session.getSessionImpl().getMyConnection().getConnectionId();
session.getSessionImpl().startRecoverConsumers();
session.getAndClearCurrentTransaction();
List recoveryList = null;
if (endRequestInDoubt())
recoveryList = XARecoverRegistry.getInstance().getRequestList(sxid);
Request request = new XAResRollbackRequest(this, session.getDispatchId(), sxid, false, recoveryList, session.getSessionImpl().getRecoveryEpoche());
request.setConnectionId(connectionId);
reply = (XAResRollbackReply) session.request(request);
} catch (Exception e) {
if (completionListener != null)
completionListener.transactionAborted(sxid);
XAException ex = new XAException(e.toString());
ex.errorCode = XAException.XAER_RMFAIL;
throw ex;
}
if (reply.isOk()) {
session.getSessionImpl().endRecoverConsumersXA();
try {
session.getSessionImpl().closeDelayedProducers();
} catch (JMSException e) {
e.printStackTrace();
}
if (completionListener != null)
completionListener.transactionAborted(sxid);
XARecoverRegistry.getInstance().clear(sxid);
} else {
if (completionListener != null)
completionListener.transactionAborted(sxid);
XAException ex = new XAException(reply.getException().getMessage());
if (reply.getErrorCode() != 0)
ex.errorCode = reply.getErrorCode();
else
ex.errorCode = XAException.XAER_RMFAIL;
throw ex;
}
}
Aggregations