Java Code Examples for javax.transaction.HeuristicRollbackException#initCause()

The following examples show how to use javax.transaction.HeuristicRollbackException#initCause() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CompensableManagerImpl.java    From ByteTCC with GNU Lesser General Public License v3.0 5 votes vote down vote up
protected void invokeTransactionCommitIfLocalTransaction(CompensableTransaction compensable) throws RollbackException,
		HeuristicMixedException, HeuristicRollbackException, SecurityException, IllegalStateException, SystemException {

	Transaction transaction = compensable.getTransaction();
	org.bytesoft.transaction.TransactionContext transactionContext = transaction.getTransactionContext();
	TransactionParticipant transactionCoordinator = this.beanFactory.getTransactionNativeParticipant();

	TransactionXid transactionXid = transactionContext.getXid();
	try {
		transactionCoordinator.end(transactionContext, XAResource.TMSUCCESS);
		transactionCoordinator.commit(transactionXid, true);
	} catch (XAException xaEx) {
		switch (xaEx.errorCode) {
		case XAException.XA_HEURCOM:
			transactionCoordinator.forgetQuietly(transactionXid);
			break;
		case XAException.XA_HEURRB:
			transactionCoordinator.forgetQuietly(transactionXid);
			HeuristicRollbackException hrex = new HeuristicRollbackException();
			hrex.initCause(xaEx);
			throw hrex;
		case XAException.XA_HEURMIX:
			transactionCoordinator.forgetQuietly(transactionXid);
			HeuristicMixedException hmex = new HeuristicMixedException();
			hmex.initCause(xaEx);
			throw hmex;
		case XAException.XAER_RMERR:
		default:
			transactionCoordinator.forgetQuietly(transactionXid); // TODO
			SystemException sysEx = new SystemException(xaEx.errorCode);
			sysEx.initCause(xaEx);
			throw sysEx;
		}
	}

}
 
Example 2
Source File: CompensableManagerImpl.java    From ByteTCC with GNU Lesser General Public License v3.0 5 votes vote down vote up
protected void invokeCompensableCommitIfLocalTransaction(CompensableTransaction compensable)
		throws HeuristicRollbackException, SystemException {

	TransactionParticipant transactionCoordinator = this.beanFactory.getTransactionNativeParticipant();
	Transaction transaction = compensable.getTransaction();
	org.bytesoft.transaction.TransactionContext transactionContext = transaction.getTransactionContext();

	TransactionXid transactionXid = transactionContext.getXid();
	try {
		transactionCoordinator.end(transactionContext, XAResource.TMSUCCESS);
		transactionCoordinator.commit(transactionXid, true);
	} catch (XAException xaex) {
		switch (xaex.errorCode) {
		case XAException.XA_HEURCOM:
			transactionCoordinator.forgetQuietly(transactionXid);
			break;
		case XAException.XA_HEURRB:
			transactionCoordinator.forgetQuietly(transactionXid);
			HeuristicRollbackException hrex = new HeuristicRollbackException();
			hrex.initCause(xaex);
			throw hrex;
		default:
			transactionCoordinator.forgetQuietly(transactionXid); // TODO
			SystemException sysEx = new SystemException(xaex.errorCode);
			sysEx.initCause(xaex);
			throw sysEx;
		}
	}
}
 
Example 3
Source File: TransactionImpl.java    From ByteJTA with GNU Lesser General Public License v3.0 4 votes vote down vote up
public synchronized void fireOnePhaseCommit()
		throws HeuristicRollbackException, HeuristicMixedException, CommitRequiredException, SystemException {

	XAResourceArchive archive = null;
	if (this.nativeParticipantList.size() > 0) {
		archive = this.nativeParticipantList.get(0);
	} else if (this.remoteParticipantList.size() > 0) {
		archive = this.remoteParticipantList.get(0);
	} else {
		archive = this.participant;
	}

	TransactionXid xid = this.transactionContext.getXid();
	try {
		this.transactionListenerList.onCommitStart(xid);
		archive.commit(xid, true);
		this.transactionListenerList.onCommitSuccess(xid);
	} catch (XAException xaex) {
		switch (xaex.errorCode) {
		case XAException.XA_HEURMIX:
			this.transactionListenerList.onCommitHeuristicMixed(xid);
			HeuristicMixedException hmex = new HeuristicMixedException();
			hmex.initCause(xaex);
			throw hmex;
		case XAException.XA_HEURCOM:
			this.transactionListenerList.onCommitSuccess(xid);
			break;
		case XAException.XA_HEURRB:
			this.transactionListenerList.onCommitHeuristicRolledback(xid);
			HeuristicRollbackException hrex = new HeuristicRollbackException();
			hrex.initCause(xaex);
			throw hrex;
		default:
			this.transactionListenerList.onCommitFailure(xid);
			SystemException ex = new SystemException();
			ex.initCause(xaex);
			throw ex;
		}
	} catch (RuntimeException rex) {
		this.transactionListenerList.onCommitFailure(xid);
		SystemException sysEx = new SystemException();
		sysEx.initCause(rex);
		throw sysEx;
	}
}