Search in sources :

Example 36 with XidImpl

use of com.swiftmq.jms.XidImpl in project swiftmq-ce by iitsoftware.

the class PreparedLog method getPreparedXids.

public List getPreparedXids() throws IOException {
    List lrList = getAll();
    List xidList = new ArrayList();
    for (int i = 0; i < lrList.size(); i++) {
        PrepareLogRecordImpl rec = (PrepareLogRecordImpl) lrList.get(i);
        XidImpl xid = rec.getGlobalTxId();
        boolean isNew = true;
        for (int j = 0; j < xidList.size(); j++) {
            if (xid.equals(xidList.get(j))) {
                isNew = false;
                break;
            }
        }
        if (isNew)
            xidList.add(xid);
    }
    return xidList;
}
Also used : XidImpl(com.swiftmq.jms.XidImpl) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList)

Example 37 with XidImpl

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 {
        List content = session.getAndClearCurrentTransaction();
        if (content != null && content.size() == 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);
}
Also used : XAException(javax.transaction.xa.XAException) XidImpl(com.swiftmq.jms.XidImpl) List(java.util.List) XAException(javax.transaction.xa.XAException)

Example 38 with XidImpl

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;
    }
}
Also used : XAException(javax.transaction.xa.XAException) XidImpl(com.swiftmq.jms.XidImpl) XAException(javax.transaction.xa.XAException)

Example 39 with XidImpl

use of com.swiftmq.jms.XidImpl in project swiftmq-ce by iitsoftware.

the class TransactionRequest method readContent.

public void readContent(DataInput input) throws IOException {
    super.readContent(input);
    sequenceNo = input.readInt();
    xid = new XidImpl();
    xid.readContent(input);
    int size = input.readInt();
    messageList = new ArrayList();
    for (int i = 0; i < size; i++) {
        MessageImpl msg = MessageImpl.createInstance(input.readInt());
        msg.readContent(input);
        messageList.add(msg);
    }
}
Also used : XidImpl(com.swiftmq.jms.XidImpl) ArrayList(java.util.ArrayList) MessageImpl(com.swiftmq.jms.MessageImpl)

Example 40 with XidImpl

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;
}
Also used : XidImpl(com.swiftmq.jms.XidImpl)

Aggregations

XidImpl (com.swiftmq.jms.XidImpl)85 XAException (javax.transaction.xa.XAException)37 JMSException (javax.jms.JMSException)28 ValidationException (com.swiftmq.tools.requestreply.ValidationException)22 Request (com.swiftmq.tools.requestreply.Request)16 List (java.util.List)12 ArrayList (java.util.ArrayList)10 XAContextException (com.swiftmq.swiftlet.xa.XAContextException)9 MessageImpl (com.swiftmq.jms.MessageImpl)6 XAContext (com.swiftmq.swiftlet.xa.XAContext)5 QueuePullTransaction (com.swiftmq.swiftlet.queue.QueuePullTransaction)4 QueueReceiver (com.swiftmq.swiftlet.queue.QueueReceiver)4 QueueSender (com.swiftmq.swiftlet.queue.QueueSender)4 BytesMessageImpl (com.swiftmq.jms.BytesMessageImpl)2 QueuePushTransaction (com.swiftmq.swiftlet.queue.QueuePushTransaction)2 Comparator (java.util.Comparator)2 CommitRequest (com.swiftmq.impl.routing.single.smqpr.v400.CommitRequest)1 CommitRequest (com.swiftmq.impl.routing.single.smqpr.v942.CommitRequest)1 QueueImpl (com.swiftmq.jms.QueueImpl)1 Entity (com.swiftmq.mgmt.Entity)1