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);
}
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);
}
}
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);
}
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);
}
}
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);
}
Aggregations