Example usage for javax.transaction.xa XAResource TMSUSPEND

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

Introduction

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

Prototype

int TMSUSPEND

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

Click Source Link

Document

Caller is suspending (not ending) its association with a transaction branch.

Usage

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

public void end(Xid xid, int flag) throws XAException {
    Map<String, LuceneIndexer> indexers = activeIndexersInGlobalTx.get(xid);

    if (indexers == null) {
        if (suspendedIndexersInGlobalTx.containsKey(xid)) {
            throw new XAException("Trying to commit indexes for a suspended transaction.");
        } else {//from  w w  w.  j  av a 2 s . c  om
            // nothing to do
            return;
        }
    }

    if (flag == XAResource.TMSUSPEND) {
        activeIndexersInGlobalTx.remove(xid);
        suspendedIndexersInGlobalTx.put(xid, indexers);
    } else if (flag == TMFAIL) {
        activeIndexersInGlobalTx.remove(xid);
        suspendedIndexersInGlobalTx.remove(xid);
    } else if (flag == TMSUCCESS) {
        activeIndexersInGlobalTx.remove(xid);
    }
}

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

public void end(Xid xid, int flag) throws XAException {
    Map<StoreRef, LuceneIndexer> indexers = activeIndexersInGlobalTx.get(xid);
    if (indexers == null) {
        if (suspendedIndexersInGlobalTx.containsKey(xid)) {
            throw new XAException("Trying to commit indexes for a suspended transaction.");
        } else {/*from w w  w. ja  va  2  s  . c o  m*/
            // nothing to do
            return;
        }
    }
    if (flag == XAResource.TMSUSPEND) {
        activeIndexersInGlobalTx.remove(xid);
        suspendedIndexersInGlobalTx.put(xid, indexers);
    } else if (flag == TMFAIL) {
        activeIndexersInGlobalTx.remove(xid);
        suspendedIndexersInGlobalTx.remove(xid);
    } else if (flag == TMSUCCESS) {
        activeIndexersInGlobalTx.remove(xid);
    }
}

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

/**
 * Send endDtx command to server/*  www . j  av  a  2s  .c o  m*/
 *
 * @param xid  a global transaction identifier to be associated with the resource
 * @param flag one of TMSUCCESS, TMFAIL, or TMSUSPEND.
 * @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 endDtx(Xid xid, int flag) throws FailoverException, AMQException, XAException {

    throwErrorIfClosed();

    if (LOGGER.isDebugEnabled()) {
        LOGGER.debug("Sending dtx.end for channel " + _channelId + ", xid " + xid);
    }

    DtxEndBody dtxEndBody = methodRegistry.createDtxEndBody(xid.getFormatId(), xid.getGlobalTransactionId(),
            xid.getBranchQualifier(), flag == XAResource.TMFAIL, flag == XAResource.TMSUSPEND);

    AMQMethodEvent amqMethodEvent = _connection._protocolHandler.syncWrite(dtxEndBody.generateFrame(_channelId),
            DtxEndOkBody.class);

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

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