Example usage for javax.transaction.xa XAException XA_RBTIMEOUT

List of usage examples for javax.transaction.xa XAException XA_RBTIMEOUT

Introduction

In this page you can find the example usage for javax.transaction.xa XAException XA_RBTIMEOUT.

Prototype

int XA_RBTIMEOUT

To view the source code for javax.transaction.xa XAException XA_RBTIMEOUT.

Click Source Link

Document

A transaction branch took too long.

Usage

From source file:org.enhydra.jdbc.standard.StandardXADataSource.java

/**
 * Checks the start of the free list to see if the connection
 * previously associated with the supplied Xid has timed out.
 * <P>//from w ww. ja v a2  s.  c o m
 * Note that this can be an expensive operation as it has to
 * scan all free connections. so it should only be called in
 * the event of an error.
 */
synchronized private void checkTimeouts(Xid xid) throws XAException {
    log.debug("StandardXADataSource:checkTimeouts");
    for (int i = 0; i < freeConnections.size(); i++) { // check each free connection
        Object o = freeConnections.elementAt(i); // get next connection
        StandardXAStatefulConnection cur = (StandardXAStatefulConnection) o;
        // cast to something more convenient
        if (!cur.timedOut) { // if it hasn't timed out
            continue; // skip it
        }
        log.debug("StandardXADataSource:checkTimeouts (" + i + "/" + freeConnections.size() + ") xid     = "
                + xid);
        log.debug("StandardXADataSource:checkTimeouts cur.xid = " + cur.xid);
        if (xid.equals(cur.xid)) { // if we've found our xid
            cur.timedOut = false; // cancel time out
            throw new XAException(XAException.XA_RBTIMEOUT);
        }
    }
}