Index: connector/src/main/org/jboss/resource/connectionmanager/TxConnectionManager.java =================================================================== --- connector/src/main/org/jboss/resource/connectionmanager/TxConnectionManager.java (revision 101393) +++ connector/src/main/org/jboss/resource/connectionmanager/TxConnectionManager.java (working copy) @@ -54,6 +54,7 @@ import org.jboss.tm.TxUtils; import org.jboss.util.NestedRuntimeException; + /** * The TxConnectionManager is a JBoss ConnectionManager * implementation for jca adapters implementing LocalTransaction and XAResource support. @@ -148,7 +149,33 @@ private boolean wrapXAResource; private Boolean isSameRMOverrideValue; - + + /** + * If system property "org.jboss.resource.connectionmanager.TxConnectionManager.ignoreStatusMarkedForRollback" is + * set to "true", checkTransactionActive() will ignore STATUS_MARKED_ROLLBACK (allowing work to continue even though + * the transaction will fail). + * Default behaviour (false) is to not allow transactional work to occur after the transaction + * is set to STATUS_MARKED_ROLLBACK. + */ + private static final boolean IGNORE_STATUS_MARKED_FOR_ROLLBACK; + + static { + + boolean value = false; + try { + String property = SecurityActions.getSystemProperty("org.jboss.resource.connectionmanager.TxConnectionManager.ignoreStatusMarkedForRollback","false"); + value = Boolean.parseBoolean(property); + if (value) // show a hint that system property was read + Logger.getLogger(TxConnectionManager.class).info( + "TxConnectionManager will allow transaction work even if tx status = STATUS_MARKED_ROLLBACK"); + } + catch(Throwable t) { + Logger.getLogger(TxConnectionManager.class).error("could not read system property 'org.jboss.resource.connectionmanager.TxConnectionManager.ignoreStatusMarkedForRollback'", t); + } + + IGNORE_STATUS_MARKED_FOR_ROLLBACK = value; + } + protected static void rethrowAsSystemException(String context, Transaction tx, Throwable t) throws SystemException { @@ -329,7 +356,12 @@ int status = tx.getStatus(); // Only allow states that will actually succeed if (status != Status.STATUS_ACTIVE && status != Status.STATUS_PREPARING && status != Status.STATUS_PREPARED && status != Status.STATUS_COMMITTING) - throw new RollbackException("Transaction " + tx + " cannot proceed " + TxUtils.getStatusAsString(status)); + { + if (status == Status.STATUS_MARKED_ROLLBACK && IGNORE_STATUS_MARKED_FOR_ROLLBACK) + ; // allow database access even though transaction is marked to fail + else + throw new RollbackException("Transaction " + tx + " cannot proceed " + TxUtils.getStatusAsString(status)); + } } } Index: connector/src/main/org/jboss/resource/connectionmanager/SecurityActions.java =================================================================== --- connector/src/main/org/jboss/resource/connectionmanager/SecurityActions.java (revision 101393) +++ connector/src/main/org/jboss/resource/connectionmanager/SecurityActions.java (working copy) @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2008, Red Hat Middleware LLC, and individual contributors + * Copyright 2010, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * @@ -42,4 +42,16 @@ return null; }}); } + + static String getSystemProperty(final String name, final String defaultValue) + { + PrivilegedAction action = new PrivilegedAction() + { + public String run() + { + return System.getProperty(name, defaultValue); + } + }; + return AccessController.doPrivileged(action); + } } \ No newline at end of file