use of com.swiftmq.jms.XidImpl 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 {
reply = (XAResPrepareReply) session.request(new XAResPrepareRequest(dispatchId, sxid));
} 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;
}
return XA_OK;
}
use of com.swiftmq.jms.XidImpl in project swiftmq-client by iitsoftware.
the class XAResourceImpl method commit.
public synchronized void commit(Xid xid, boolean onePhase) throws XAException {
if (logWriter != null)
log(toString() + "/commit, xid=" + xid + ", onePhase=" + onePhase);
XidImpl sxid = toSwiftMQXid(xid);
xidMapping.remove(xid);
XAResCommitReply reply = null;
try {
XAResCommitRequest req = new XAResCommitRequest(dispatchId, sxid, onePhase);
reply = (XAResCommitReply) session.request(req);
} catch (Exception e) {
if (completionListener != null)
completionListener.transactionCommitted(sxid);
XAException ex = new XAException(e.toString());
ex.errorCode = XAException.XAER_RMFAIL;
throw ex;
}
if (!reply.isOk()) {
if (completionListener != null)
completionListener.transactionCommitted(sxid);
XAException ex = new XAException(reply.getException().getMessage());
ex.errorCode = reply.getErrorCode();
throw ex;
} else {
if (reply.getDelay() > 0) {
try {
Thread.sleep(reply.getDelay());
} catch (Exception ignored) {
}
}
if (completionListener != null)
completionListener.transactionCommitted(sxid);
}
}
use of com.swiftmq.jms.XidImpl in project swiftmq-client by iitsoftware.
the class XAResourceImpl method toSwiftMQXid.
private XidImpl toSwiftMQXid(Xid xid) {
XidImpl rXid = null;
if (xid instanceof com.swiftmq.jms.XidImpl)
rXid = (XidImpl) xid;
else {
rXid = (XidImpl) xidMapping.get(xid);
if (rXid == null) {
rXid = new XidImpl(xid);
xidMapping.put(xid, rXid);
}
}
if (logWriter != null)
log(toString() + "/toSwiftMQXid, xid=" + xid + ", rXid=" + rXid);
return rXid;
}
use of com.swiftmq.jms.XidImpl 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 {
reply = (XAResPrepareReply) session.request(new XAResPrepareRequest(dispatchId, sxid));
} 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;
}
return XA_OK;
}
use of com.swiftmq.jms.XidImpl in project swiftmq-client by iitsoftware.
the class XAResourceImpl method commit.
public synchronized void commit(Xid xid, boolean onePhase) throws XAException {
if (logWriter != null)
log(toString() + "/commit, xid=" + xid + ", onePhase=" + onePhase);
XidImpl sxid = toSwiftMQXid(xid);
xidMapping.remove(xid);
XAResCommitReply reply = null;
try {
XAResCommitRequest req = new XAResCommitRequest(dispatchId, sxid, onePhase);
reply = (XAResCommitReply) session.request(req);
} catch (Exception e) {
if (completionListener != null)
completionListener.transactionCommitted(sxid);
XAException ex = new XAException(e.toString());
ex.errorCode = XAException.XAER_RMFAIL;
throw ex;
}
if (!reply.isOk()) {
if (completionListener != null)
completionListener.transactionCommitted(sxid);
XAException ex = new XAException(reply.getException().getMessage());
ex.errorCode = reply.getErrorCode();
throw ex;
} else {
if (reply.getDelay() > 0) {
try {
Thread.sleep(reply.getDelay());
} catch (Exception ignored) {
}
}
if (completionListener != null)
completionListener.transactionCommitted(sxid);
}
}
Aggregations