Search in sources :

Example 1 with XidImpl

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;
    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());
        if (reply.getErrorCode() != 0)
            ex.errorCode = reply.getErrorCode();
        else
            ex.errorCode = XAException.XAER_RMFAIL;
        throw ex;
    } else {
        XARecoverRegistry.getInstance().addRequest(sxid, request);
        try {
            session.session.assignLastMessage();
        } catch (Exception e) {
            XAException ex = new XAException(reply.getException().getMessage());
            if (reply.getErrorCode() != 0)
                ex.errorCode = reply.getErrorCode();
            else
                ex.errorCode = XAException.XAER_RMFAIL;
            throw ex;
        }
    }
    if (completionListener != null)
        completionListener.transactionStarted(sxid, session);
}
Also used : XAException(javax.transaction.xa.XAException) XidImpl(com.swiftmq.jms.XidImpl) Request(com.swiftmq.tools.requestreply.Request) ValidationException(com.swiftmq.tools.requestreply.ValidationException) JMSException(javax.jms.JMSException) XAException(javax.transaction.xa.XAException)

Example 2 with XidImpl

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

the class XAResourceImpl method forget.

public synchronized void forget(Xid xid) throws XAException {
    if (logWriter != null)
        log(toString() + "/forget, xid=" + xid);
    XidImpl sxid = toSwiftMQXid(xid);
    xidMapping.remove(xid);
    XAResForgetReply reply = null;
    try {
        int connectionId = session.getSessionImpl().getMyConnection().getConnectionId();
        Request request = new XAResForgetRequest(this, session.getDispatchId(), sxid, false);
        request.setConnectionId(connectionId);
        reply = (XAResForgetReply) 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;
    }
}
Also used : XAException(javax.transaction.xa.XAException) XidImpl(com.swiftmq.jms.XidImpl) Request(com.swiftmq.tools.requestreply.Request) ValidationException(com.swiftmq.tools.requestreply.ValidationException) JMSException(javax.jms.JMSException) XAException(javax.transaction.xa.XAException)

Example 3 with XidImpl

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

Example 4 with XidImpl

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;
    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());
        if (reply.getErrorCode() != 0)
            ex.errorCode = reply.getErrorCode();
        else
            ex.errorCode = XAException.XAER_RMFAIL;
        throw ex;
    } else {
        XARecoverRegistry.getInstance().addRequest(sxid, request);
        try {
            session.session.assignLastMessage();
        } catch (Exception e) {
            XAException ex = new XAException(reply.getException().getMessage());
            if (reply.getErrorCode() != 0)
                ex.errorCode = reply.getErrorCode();
            else
                ex.errorCode = XAException.XAER_RMFAIL;
            throw ex;
        }
    }
    if (completionListener != null)
        completionListener.transactionStarted(sxid, session);
}
Also used : XAException(javax.transaction.xa.XAException) XidImpl(com.swiftmq.jms.XidImpl) Request(com.swiftmq.tools.requestreply.Request) ValidationException(com.swiftmq.tools.requestreply.ValidationException) JMSException(javax.jms.JMSException) XAException(javax.transaction.xa.XAException)

Example 5 with XidImpl

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

the class XAResourceImpl method forget.

public synchronized void forget(Xid xid) throws XAException {
    if (logWriter != null)
        log(toString() + "/forget, xid=" + xid);
    XidImpl sxid = toSwiftMQXid(xid);
    xidMapping.remove(xid);
    XAResForgetReply reply = null;
    try {
        int connectionId = session.getSessionImpl().getMyConnection().getConnectionId();
        Request request = new XAResForgetRequest(this, session.getDispatchId(), sxid, false);
        request.setConnectionId(connectionId);
        reply = (XAResForgetReply) 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;
    }
}
Also used : XAException(javax.transaction.xa.XAException) XidImpl(com.swiftmq.jms.XidImpl) Request(com.swiftmq.tools.requestreply.Request) ValidationException(com.swiftmq.tools.requestreply.ValidationException) JMSException(javax.jms.JMSException) XAException(javax.transaction.xa.XAException)

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