Example usage for javax.transaction.xa XAResource TMRESUME

List of usage examples for javax.transaction.xa XAResource TMRESUME

Introduction

In this page you can find the example usage for javax.transaction.xa XAResource TMRESUME.

Prototype

int TMRESUME

To view the source code for javax.transaction.xa XAResource TMRESUME.

Click Source Link

Document

Caller is resuming association with a suspended transaction branch.

Usage

From source file:it.doqui.index.ecmengine.business.personalization.multirepository.index.lucene.RepositoryAwareAbstractLuceneIndexerAndSearcherFactory.java

public void start(Xid xid, int flag) throws XAException {

    Map<String, LuceneIndexer> active = activeIndexersInGlobalTx.get(xid);
    Map<String, LuceneIndexer> suspended = suspendedIndexersInGlobalTx.get(xid);

    if (flag == XAResource.TMJOIN) {
        // must be active
        if ((active != null) && (suspended == null)) {
            return;
        } else {//from  www . j  av  a2 s. com
            throw new XAException("Trying to rejoin transaction in an invalid state");
        }

    } else if (flag == XAResource.TMRESUME) {
        // must be suspended
        if ((active == null) && (suspended != null)) {
            suspendedIndexersInGlobalTx.remove(xid);
            activeIndexersInGlobalTx.put(xid, suspended);
            return;
        } else {
            throw new XAException("Trying to rejoin transaction in an invalid state");
        }

    } else if (flag == XAResource.TMNOFLAGS) {
        if ((active == null) && (suspended == null)) {
            return;
        } else {
            throw new XAException("Trying to start an existing or suspended transaction");
        }
    } else {
        throw new XAException("Unkown flags for start " + flag);
    }
}

From source file:org.alfresco.repo.search.impl.lucene.AbstractLuceneIndexerAndSearcherFactory.java

public void start(Xid xid, int flag) throws XAException {
    Map<StoreRef, LuceneIndexer> active = activeIndexersInGlobalTx.get(xid);
    Map<StoreRef, LuceneIndexer> suspended = suspendedIndexersInGlobalTx.get(xid);
    if (flag == XAResource.TMJOIN) {
        // must be active
        if ((active != null) && (suspended == null)) {
            return;
        } else {//from  w  w w .j  a v a 2 s.  c o  m
            throw new XAException("Trying to rejoin transaction in an invalid state");
        }

    } else if (flag == XAResource.TMRESUME) {
        // must be suspended
        if ((active == null) && (suspended != null)) {
            suspendedIndexersInGlobalTx.remove(xid);
            activeIndexersInGlobalTx.put(xid, suspended);
            return;
        } else {
            throw new XAException("Trying to rejoin transaction in an invalid state");
        }

    } else if (flag == XAResource.TMNOFLAGS) {
        if ((active == null) && (suspended == null)) {
            return;
        } else {
            throw new XAException("Trying to start an existing or suspended transaction");
        }
    } else {
        throw new XAException("Unkown flags for start " + flag);
    }

}

From source file:org.wso2.andes.client.XASession_9_1.java

/**
 * Send startDtx command to server/*from w  w w  . j  a  va  2s  . c  o  m*/
 *
 * @param xid  q global transaction identifier to be associated with the resource
 * @param flag one of TMNOFLAGS, TMJOIN, or TMRESUME
 * @return XaStatus returned by server
 * @throws FailoverException when a connection issue is detected
 * @throws AMQException      when an error is detected in AMQ state manager
 */
XaStatus startDtx(Xid xid, int flag) throws FailoverException, AMQException, XAException {

    throwErrorIfClosed();

    DtxStartBody dtxStartBody = methodRegistry.createDtxStartBody(xid.getFormatId(),
            xid.getGlobalTransactionId(), xid.getBranchQualifier(), flag == XAResource.TMJOIN,
            flag == XAResource.TMRESUME);

    AMQMethodEvent amqMethodEvent = _connection._protocolHandler
            .syncWrite(dtxStartBody.generateFrame(_channelId), DtxStartOkBody.class);

    DtxStartOkBodyImpl response = (DtxStartOkBodyImpl) amqMethodEvent.getMethod();

    return XaStatus.valueOf(response.getXaResult());
}