Example usage for javax.transaction.xa XAResource TMENDRSCAN

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

Introduction

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

Prototype

int TMENDRSCAN

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

Click Source Link

Document

Ends a recovery scan.

Usage

From source file:org.mule.util.xa.XaTransactionRecoverer.java

public synchronized Xid[] recover(int flag) throws XAException {
    //No need to do anything for XAResource.TMENDRSCAN
    if (flag == XAResource.TMENDRSCAN) {
        return new Xid[0];
    }/*from w  ww .j a  v  a  2  s .com*/
    //For XAResource.TMSTARTRSCAN and XAResource.TMNOFLAGS (only possible values despite XAResource.TMENDRSCAN we returns
    //the set of Xid to recover (no commit, no rollback) and bitronix will commit, rollback for Xid that are
    //dangling transactions and will do nothing for those that are currently being executed.
    Multimap<Xid, XaQueueTxJournalEntry> xidXaJournalEntryMultimap = xaTxQueueTransactionJournal
            .getAllLogEntries();
    if (logger.isDebugEnabled()) {
        logger.debug("Executing XA recover");
        logger.debug("Found " + xidXaJournalEntryMultimap.size() + " in the tx log");
    }
    List<Xid> txsToRecover = new ArrayList<Xid>();
    for (Xid xid : xidXaJournalEntryMultimap.keySet()) {
        Collection<XaQueueTxJournalEntry> entries = xidXaJournalEntryMultimap.get(xid);
        Object commitOrRollback = CollectionUtils.find(entries, new Predicate() {
            @Override
            public boolean evaluate(Object object) {
                XaQueueTxJournalEntry logEntry = (XaQueueTxJournalEntry) object;
                return logEntry.isCommit() || logEntry.isRollback();
            }
        });
        if (commitOrRollback != null) {
            continue;
        }
        txsToRecover.add(xid);
    }
    if (logger.isDebugEnabled()) {
        logger.debug("found " + txsToRecover.size() + " txs to recover");
    }
    return txsToRecover.toArray(new Xid[txsToRecover.size()]);
}

From source file:org.springframework.boot.jta.narayana.DataSourceXAResourceRecoveryHelper.java

@Override
public Xid[] recover(int flag) throws XAException {
    try {//from   ww  w.ja v a 2 s  . c  o m
        return getDelegate(true).recover(flag);
    } finally {
        if (flag == XAResource.TMENDRSCAN) {
            disconnect();
        }
    }
}