Search in sources :

Example 6 with ResourceManagerException

use of org.mule.runtime.core.api.transaction.xa.ResourceManagerException in project mule by mulesoft.

the class DefaultXASession method commit.

public void commit(Xid xid, boolean onePhase) throws XAException {
    if (xid == null) {
        throw new XAException(XAException.XAER_PROTO);
    }
    T context = resourceManager.getActiveTransactionalResource(xid);
    if (context == null) {
        if (logger.isDebugEnabled()) {
            logger.debug("Commit called without a transaction context");
        }
        commitDanglingTransaction(xid, onePhase);
        return;
    }
    if (logger.isDebugEnabled()) {
        logger.debug("Committing transaction branch " + xid);
    }
    if (context.status == Status.STATUS_MARKED_ROLLBACK) {
        throw new XAException(XAException.XA_RBROLLBACK);
    }
    try {
        if (context.status != Status.STATUS_PREPARED) {
            if (onePhase) {
                resourceManager.prepareTransaction(context);
            } else {
                throw new XAException(XAException.XAER_PROTO);
            }
        }
        resourceManager.commitTransaction(context);
        localContext = null;
    } catch (ResourceManagerException e) {
        throw (XAException) new XAException(XAException.XAER_RMERR).initCause(e);
    }
    resourceManager.removeActiveTransactionalResource(xid);
    resourceManager.removeSuspendedTransactionalResource(xid);
}
Also used : XAException(javax.transaction.xa.XAException) ResourceManagerException(org.mule.runtime.core.api.transaction.xa.ResourceManagerException)

Example 7 with ResourceManagerException

use of org.mule.runtime.core.api.transaction.xa.ResourceManagerException in project mule by mulesoft.

the class PersistentQueueTransactionContext method doCommit.

@Override
public void doCommit() throws ResourceManagerException {
    try {
        Collection<LocalQueueTxJournalEntry> logEntries = this.transactionJournal.getLogEntriesForTx(txId);
        for (LocalQueueTxJournalEntry entry : logEntries) {
            if (entry.isAdd()) {
                queueProvider.getQueue(entry.getQueueName()).putNow(entry.getValue());
            } else if (entry.isAddFirst()) {
                queueProvider.getQueue(entry.getQueueName()).untake(entry.getValue());
            }
        }
        this.transactionJournal.logCommit(txId);
    } catch (Exception e) {
        throw new ResourceManagerException(e);
    }
}
Also used : LocalQueueTxJournalEntry(org.mule.runtime.core.internal.util.journal.queue.LocalQueueTxJournalEntry) ResourceManagerException(org.mule.runtime.core.api.transaction.xa.ResourceManagerException) ResourceManagerException(org.mule.runtime.core.api.transaction.xa.ResourceManagerException)

Example 8 with ResourceManagerException

use of org.mule.runtime.core.api.transaction.xa.ResourceManagerException in project mule by mulesoft.

the class PersistentQueueTransactionContext method doRollback.

@Override
public void doRollback() throws ResourceManagerException {
    Collection<LocalQueueTxJournalEntry> logEntries = this.transactionJournal.getLogEntriesForTx(txId);
    for (LocalQueueTxJournalEntry entry : logEntries) {
        if (entry.isRemove()) {
            try {
                queueProvider.getQueue(entry.getQueueName()).putNow(entry.getValue());
            } catch (InterruptedException e) {
                throw new ResourceManagerException(e);
            }
        }
    }
    this.transactionJournal.logRollback(txId);
}
Also used : LocalQueueTxJournalEntry(org.mule.runtime.core.internal.util.journal.queue.LocalQueueTxJournalEntry) ResourceManagerException(org.mule.runtime.core.api.transaction.xa.ResourceManagerException)

Example 9 with ResourceManagerException

use of org.mule.runtime.core.api.transaction.xa.ResourceManagerException in project mule by mulesoft.

the class PersistentXaTransactionContext method doCommit.

@Override
public void doCommit() throws ResourceManagerException {
    try {
        Collection<XaQueueTxJournalEntry> logEntries = this.transactionJournal.getLogEntriesForTx(xid);
        for (XaQueueTxJournalEntry entry : logEntries) {
            if (entry.isAdd()) {
                queueProvider.getQueue(entry.getQueueName()).putNow(entry.getValue());
            } else if (entry.isAddFirst()) {
                queueProvider.getQueue(entry.getQueueName()).untake(entry.getValue());
            }
        }
        this.transactionJournal.logCommit(xid);
    } catch (Exception e) {
        throw new ResourceManagerException(e);
    }
}
Also used : XaQueueTxJournalEntry(org.mule.runtime.core.internal.util.journal.queue.XaQueueTxJournalEntry) ResourceManagerException(org.mule.runtime.core.api.transaction.xa.ResourceManagerException) ResourceManagerException(org.mule.runtime.core.api.transaction.xa.ResourceManagerException)

Example 10 with ResourceManagerException

use of org.mule.runtime.core.api.transaction.xa.ResourceManagerException in project mule by mulesoft.

the class PersistentXaTransactionContext method doRollback.

@Override
public void doRollback() throws ResourceManagerException {
    Collection<XaQueueTxJournalEntry> logEntries = this.transactionJournal.getLogEntriesForTx(xid);
    for (XaQueueTxJournalEntry entry : logEntries) {
        if (entry.isRemove()) {
            try {
                queueProvider.getQueue(entry.getQueueName()).putNow(entry.getValue());
            } catch (InterruptedException e) {
                throw new ResourceManagerException(e);
            }
        }
    }
    this.transactionJournal.logRollback(xid);
}
Also used : XaQueueTxJournalEntry(org.mule.runtime.core.internal.util.journal.queue.XaQueueTxJournalEntry) ResourceManagerException(org.mule.runtime.core.api.transaction.xa.ResourceManagerException)

Aggregations

ResourceManagerException (org.mule.runtime.core.api.transaction.xa.ResourceManagerException)11 XAException (javax.transaction.xa.XAException)5 Serializable (java.io.Serializable)2 LocalQueueTxJournalEntry (org.mule.runtime.core.internal.util.journal.queue.LocalQueueTxJournalEntry)2 XaQueueTxJournalEntry (org.mule.runtime.core.internal.util.journal.queue.XaQueueTxJournalEntry)2 PersistentXaTransactionContext (org.mule.runtime.core.internal.util.queue.PersistentXaTransactionContext)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 Test (org.junit.Test)1 MuleRuntimeException (org.mule.runtime.api.exception.MuleRuntimeException)1 DefaultQueueConfiguration (org.mule.runtime.core.api.util.queue.DefaultQueueConfiguration)1 LocalTxQueueTransactionRecoverer (org.mule.runtime.core.internal.util.journal.queue.LocalTxQueueTransactionRecoverer)1