fix issue introduced in https://issues.apache.org/jira/browse/AMQ-4019 for XA connections.

git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@1406657 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Timothy A. Bish 2012-11-07 14:34:47 +00:00
parent 8516331c96
commit 8b84374cdb
3 changed files with 20 additions and 1 deletions

View File

@ -130,7 +130,7 @@ public class PooledConnectionFactory implements ConnectionFactory, Service {
public ConnectionPool makeObject(ConnectionKey key) throws Exception {
ActiveMQConnection delegate = createConnection(key);
ConnectionPool connection = new ConnectionPool(delegate);
ConnectionPool connection = createConnectionPool(delegate);
connection.setIdleTimeout(getIdleTimeout());
connection.setExpiryTimeout(getExpiryTimeout());
connection.setMaximumActiveSessionPerConnection(getMaximumActiveSessionPerConnection());
@ -484,4 +484,16 @@ public class PooledConnectionFactory implements ConnectionFactory, Service {
*/
public void setPoolFactory(ObjectPoolFactory<?> factory) {
}
/**
* Delegate that creates each instance of an ConnectionPool object. Subclasses can override
* this method to customize the type of connection pool returned.
*
* @param connection
*
* @return instance of a new ConnectionPool.
*/
protected ConnectionPool createConnectionPool(ActiveMQConnection connection) {
return new ConnectionPool(connection);
}
}

View File

@ -49,6 +49,7 @@ public class XaPooledConnectionFactory extends PooledConnectionFactory {
this.transactionManager = transactionManager;
}
@Override
protected ConnectionPool createConnectionPool(ActiveMQConnection connection) {
return new XaConnectionPool(connection, getTransactionManager());
}

View File

@ -33,6 +33,7 @@ import javax.transaction.Transaction;
import javax.transaction.TransactionManager;
import javax.transaction.xa.XAResource;
import org.apache.activemq.ActiveMQXAConnectionFactory;
import org.apache.activemq.ActiveMQXASession;
import org.apache.activemq.command.ActiveMQTopic;
import org.apache.activemq.test.TestSupport;
@ -122,6 +123,11 @@ public class XAConnectionPoolTest extends TestSupport {
TopicConnection connection = (TopicConnection) pcf.createConnection();
TopicSession session = connection.createTopicSession(false, Session.AUTO_ACKNOWLEDGE);
assertTrue(session instanceof PooledSession);
PooledSession pooledSession = (PooledSession) session;
assertTrue(pooledSession.getInternalSession() instanceof ActiveMQXASession);
TopicPublisher publisher = session.createPublisher(topic);
publisher.publish(session.createMessage());