Example usage for org.springframework.transaction HeuristicCompletionException STATE_MIXED

List of usage examples for org.springframework.transaction HeuristicCompletionException STATE_MIXED

Introduction

In this page you can find the example usage for org.springframework.transaction HeuristicCompletionException STATE_MIXED.

Prototype

int STATE_MIXED

To view the source code for org.springframework.transaction HeuristicCompletionException STATE_MIXED.

Click Source Link

Document

Mixed outcome state.

Usage

From source file:bigbank.transaction.ChainedTransactionManager.java

@Override
public void commit(TransactionStatus status) throws TransactionException {

    MultiTransactionStatus multiTransactionStatus = (MultiTransactionStatus) status;

    boolean commit = true;
    Exception commitException = null;
    PlatformTransactionManager commitExceptionTransactionManager = null;

    for (PlatformTransactionManager transactionManager : reverse(transactionManagers)) {
        if (commit) {
            try {
                multiTransactionStatus.commit(transactionManager);
            } catch (Exception ex) {
                commit = false;/*from w  w w .j av  a  2  s  .co  m*/
                commitException = ex;
                commitExceptionTransactionManager = transactionManager;
            }
        } else {
            // after unsucessfull commit we must try to rollback remaining
            // transaction managers
            try {
                multiTransactionStatus.rollback(transactionManager);
            } catch (Exception ex) {
                logger.warn("Rollback exception (after commit) (" + transactionManager + ") " + ex.getMessage(),
                        ex);
            }
        }
    }

    if (multiTransactionStatus.isNewSynchonization()) {
        synchronizationManager.clearSynchronization();
    }

    if (commitException != null) {
        boolean firstTransactionManagerFailed = commitExceptionTransactionManager == getLastTransactionManager();
        int transactionState = firstTransactionManagerFailed ? HeuristicCompletionException.STATE_ROLLED_BACK
                : HeuristicCompletionException.STATE_MIXED;
        throw new HeuristicCompletionException(transactionState, commitException);
    }

}

From source file:com.zhengmo.data.transaction.ChainedTransactionManager.java

@Override
public void commit(TransactionStatus status) throws TransactionException {
    MultiTransactionStatus multiTransactionStatus = (MultiTransactionStatus) status;
    boolean commit = true;
    Exception commitException = null;
    PlatformTransactionManager commitExceptionTransactionManager = null;
    for (PlatformTransactionManager transactionManager : reverse(transactionManagers)) {
        if (commit) {
            try {
                multiTransactionStatus.commit(transactionManager);
            } catch (Exception ex) {
                commit = false;/*from   w w w. j  a v a  2s. com*/
                commitException = ex;
                commitExceptionTransactionManager = transactionManager;
            }
        } else {
            // after unsucessfull commit we must try to rollback remaining transaction managers
            try {
                multiTransactionStatus.rollback(transactionManager);
            } catch (Exception ex) {
                LOGGER.warn("Rollback exception (after commit) (" + transactionManager + ") " + ex.getMessage(),
                        ex);
            }
        }
    }
    if (multiTransactionStatus.isNewSynchonization()) {
        synchronizationManager.clearSynchronization();
    }
    if (commitException != null) {
        boolean firstTransactionManagerFailed = commitExceptionTransactionManager == getLastTransactionManager();
        int transactionState = firstTransactionManagerFailed ? HeuristicCompletionException.STATE_ROLLED_BACK
                : HeuristicCompletionException.STATE_MIXED;
        throw new HeuristicCompletionException(transactionState, commitException);
    }
}

From source file:com.becool.base.spring.tx.ChainedTransactionManager.java

public void commit(TransactionStatus status) throws TransactionException {

    MultiTransactionStatus multiTransactionStatus = (MultiTransactionStatus) status;

    boolean commit = true;
    Exception commitException = null;
    PlatformTransactionManager commitExceptionTransactionManager = null;

    for (PlatformTransactionManager transactionManager : reverse(transactionManagers)) {

        if (commit) {

            try {
                multiTransactionStatus.commit(transactionManager);
            } catch (Exception ex) {
                commit = false;//from   w w w  .  ja v a  2  s  . c  o  m
                commitException = ex;
                commitExceptionTransactionManager = transactionManager;
            }

        } else {

            // after unsucessfull commit we must try to rollback remaining transaction managers

            try {
                multiTransactionStatus.rollback(transactionManager);
            } catch (Exception ex) {
                LOGGER.warn("Rollback exception (after commit) (" + transactionManager + ") " + ex.getMessage(),
                        ex);
            }
        }
    }
    if (multiTransactionStatus.isNewSynchonization()) {
        synchronizationManager.clearSynchronization();
    }

    if (commitException != null) {
        boolean firstTransactionManagerFailed = commitExceptionTransactionManager == getLastTransactionManager();
        int transactionState = firstTransactionManagerFailed ? HeuristicCompletionException.STATE_ROLLED_BACK
                : HeuristicCompletionException.STATE_MIXED;
        throw new HeuristicCompletionException(transactionState, commitException);
    }
}

From source file:org.danielli.xultimate.transaction.ChainedTransactionManager.java

public void commit(TransactionStatus status) throws TransactionException {

    MultiTransactionStatus multiTransactionStatus = (MultiTransactionStatus) status;

    boolean commit = true;
    Exception commitException = null;
    PlatformTransactionManager commitExceptionTransactionManager = null;

    for (PlatformTransactionManager transactionManager : reverse(transactionManagers)) {

        if (commit) {

            try {
                multiTransactionStatus.commit(transactionManager);
            } catch (Exception ex) {
                commit = false;/*from  w ww  .  ja  v a  2 s  .c o m*/
                commitException = ex;
                commitExceptionTransactionManager = transactionManager;
            }

        } else {

            // after unsucessfull commit we must try to rollback remaining transaction managers

            try {
                multiTransactionStatus.rollback(transactionManager);
            } catch (Exception ex) {
                LOGGER.warn("Rollback exception (after commit) (" + transactionManager + ") " + ex.getMessage(),
                        ex);
            }
        }
    }

    if (multiTransactionStatus.isNewSynchonization()) {
        synchronizationManager.clearSynchronization();
    }

    if (commitException != null) {
        boolean firstTransactionManagerFailed = commitExceptionTransactionManager == getLastTransactionManager();
        int transactionState = firstTransactionManagerFailed ? HeuristicCompletionException.STATE_ROLLED_BACK
                : HeuristicCompletionException.STATE_MIXED;
        throw new HeuristicCompletionException(transactionState, commitException);
    }
}

From source file:de.faustedition.db.ChainedTransactionManager.java

@Override
public void commit(TransactionStatus status) throws TransactionException {

    MultiTransactionStatus multiTransactionStatus = (MultiTransactionStatus) status;

    boolean commit = true;
    Exception commitException = null;
    PlatformTransactionManager commitExceptionTransactionManager = null;

    for (PlatformTransactionManager transactionManager : reverse(transactionManagers)) {
        if (commit) {
            try {
                multiTransactionStatus.commit(transactionManager);
            } catch (Exception ex) {
                commit = false;//ww  w.  j a  v a  2s. co  m
                commitException = ex;
                commitExceptionTransactionManager = transactionManager;
            }
        } else {
            //after unsucessfull commit we must try to rollback remaining transaction managers
            try {
                multiTransactionStatus.rollback(transactionManager);
            } catch (Exception ex) {
                logger.warn("Rollback exception (after commit) (" + transactionManager + ") " + ex.getMessage(),
                        ex);
            }
        }
    }

    if (multiTransactionStatus.isNewSynchonization()) {
        synchronizationManager.clearSynchronization();
    }

    if (commitException != null) {
        boolean firstTransactionManagerFailed = commitExceptionTransactionManager == getLastTransactionManager();
        int transactionState = firstTransactionManagerFailed ? HeuristicCompletionException.STATE_ROLLED_BACK
                : HeuristicCompletionException.STATE_MIXED;
        throw new HeuristicCompletionException(transactionState, commitException);
    }

}