use of com.swiftmq.jms.XidImpl in project swiftmq-client by iitsoftware.
the class XAResRollbackRequest method readContent.
public void readContent(DataInput in) throws IOException {
super.readContent(in);
xid = new XidImpl();
xid.readContent(in);
}
use of com.swiftmq.jms.XidImpl 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 {
session.getSessionImpl().startRecoverConsumers();
session.getAndClearCurrentTransaction();
reply = (XAResRollbackReply) session.request(new XAResRollbackRequest(dispatchId, sxid));
} 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().endRecoverConsumers();
if (completionListener != null)
completionListener.transactionAborted(sxid);
} else {
if (completionListener != null)
completionListener.transactionAborted(sxid);
XAException ex = new XAException(reply.getException().getMessage());
ex.errorCode = reply.getErrorCode();
throw ex;
}
}
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 end.
public synchronized void end(Xid xid, int flags) throws XAException {
if (logWriter != null)
log(toString() + "/end, xid=" + xid + ", flags=" + flags);
XidImpl sxid = toSwiftMQXid(xid);
XAResEndReply reply = null;
try {
Object[] content = session.getAndClearCurrentTransaction();
if (content != null && content.length == 0)
content = null;
reply = (XAResEndReply) session.request(new XAResEndRequest(dispatchId, sxid, flags, content));
} 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;
}
if (completionListener != null)
completionListener.transactionEnded(sxid);
}
use of com.swiftmq.jms.XidImpl 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;
try {
reply = (XAResStartReply) session.request(new XAResStartRequest(dispatchId, sxid, flags));
} 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 {
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