https://issues.apache.org/jira/browse/AMQ-4426 - for cmt, ignore args to create session when tm and no tx, so session_transacted is not passed down to cf, avoid config error ex

git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@1463908 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Gary Tully 2013-04-03 10:35:56 +00:00
parent 07c3db5eeb
commit a3578eb91b
2 changed files with 62 additions and 0 deletions

View File

@ -48,6 +48,12 @@ public class XaConnectionPool extends ConnectionPool {
if (isXa) {
transacted = true;
ackMode = Session.SESSION_TRANSACTED;
} else if (transactionManager != null) {
// cmt or transactionManager managed
transacted = false;
if (ackMode == Session.SESSION_TRANSACTED) {
ackMode = Session.AUTO_ACKNOWLEDGE;
}
}
PooledSession session = (PooledSession) super.createSession(transacted, ackMode);
if (isXa) {

View File

@ -191,4 +191,60 @@ public class XAConnectionPoolTest extends TestSupport {
topicConnection.close();
}
public void testSessionArgsIgnoredWithTm() throws Exception {
XaPooledConnectionFactory pcf = new XaPooledConnectionFactory();
pcf.setConnectionFactory(new ActiveMQConnectionFactory("vm://test?broker.persistent=false"));
// simple TM that with no tx
pcf.setTransactionManager(new TransactionManager() {
@Override
public void begin() throws NotSupportedException, SystemException {
throw new SystemException("NoTx");
}
@Override
public void commit() throws HeuristicMixedException, HeuristicRollbackException, IllegalStateException, RollbackException, SecurityException, SystemException {
throw new IllegalStateException("NoTx");
}
@Override
public int getStatus() throws SystemException {
return Status.STATUS_NO_TRANSACTION;
}
@Override
public Transaction getTransaction() throws SystemException {
throw new SystemException("NoTx");
}
@Override
public void resume(Transaction tobj) throws IllegalStateException, InvalidTransactionException, SystemException {
throw new IllegalStateException("NoTx");
}
@Override
public void rollback() throws IllegalStateException, SecurityException, SystemException {
throw new IllegalStateException("NoTx");
}
@Override
public void setRollbackOnly() throws IllegalStateException, SystemException {
throw new IllegalStateException("NoTx");
}
@Override
public void setTransactionTimeout(int seconds) throws SystemException {
}
@Override
public Transaction suspend() throws SystemException {
throw new SystemException("NoTx");
}
});
QueueConnection connection = pcf.createQueueConnection();
// like ee tck
assertNotNull("can create session(false, 0)", connection.createQueueSession(false, 0));
connection.close();
}
}