diff --git a/activemq-pool/src/main/java/org/apache/activemq/pool/AmqJNDIPooledConnectionFactory.java b/activemq-pool/src/main/java/org/apache/activemq/pool/AmqJNDIPooledConnectionFactory.java index f89bbff38b..78cbcb8f23 100644 --- a/activemq-pool/src/main/java/org/apache/activemq/pool/AmqJNDIPooledConnectionFactory.java +++ b/activemq-pool/src/main/java/org/apache/activemq/pool/AmqJNDIPooledConnectionFactory.java @@ -89,6 +89,10 @@ public class AmqJNDIPooledConnectionFactory extends PooledConnectionFactory if (temp != null && temp.length() > 0) { setMaximumActive(Integer.parseInt(temp)); } + temp = properties.getProperty("maximumActiveSessionPerConnection"); + if (temp != null && temp.length() > 0) { + setMaximumActiveSessionPerConnection(Integer.parseInt(temp)); + } temp = properties.getProperty("maxConnections"); if (temp != null && temp.length() > 0) { setMaxConnections(Integer.parseInt(temp)); @@ -98,9 +102,10 @@ public class AmqJNDIPooledConnectionFactory extends PooledConnectionFactory public void populateProperties(Properties props) { ((ActiveMQConnectionFactory) getConnectionFactory()) .populateProperties(props); - props - .setProperty("maximumActive", Integer - .toString(getMaximumActive())); + props.setProperty("maximumActive", Integer + .toString(getMaximumActive())); + props.setProperty("maximumActiveSessionPerConnection", Integer + .toString(getMaximumActiveSessionPerConnection())); props.setProperty("maxConnections", Integer .toString(getMaxConnections())); } diff --git a/activemq-pool/src/main/java/org/apache/activemq/pool/PooledConnectionFactory.java b/activemq-pool/src/main/java/org/apache/activemq/pool/PooledConnectionFactory.java index 6be8cf627f..2263b06469 100644 --- a/activemq-pool/src/main/java/org/apache/activemq/pool/PooledConnectionFactory.java +++ b/activemq-pool/src/main/java/org/apache/activemq/pool/PooledConnectionFactory.java @@ -63,7 +63,7 @@ public class PooledConnectionFactory implements ConnectionFactory, Service { private ConnectionFactory connectionFactory; private final Map> cache = new HashMap>(); private ObjectPoolFactory poolFactory; - private int maximumActive = 500; + private int maximumActiveSessionPerConnection = 500; private int maxConnections = 1; private int idleTimeout = 30 * 1000; private boolean blockIfSessionPoolIsFull = true; @@ -193,15 +193,31 @@ public class PooledConnectionFactory implements ConnectionFactory, Service { this.poolFactory = poolFactory; } + /** + * @deprecated use {@link #getMaximumActiveSessionPerConnection()} + */ + @Deprecated public int getMaximumActive() { - return maximumActive; + return getMaximumActiveSessionPerConnection(); + } + + /** + * @deprecated use {@link #setMaximumActiveSessionPerConnection(int)} + */ + @Deprecated + public void setMaximumActive(int maximumActive) { + setMaximumActiveSessionPerConnection(maximumActive); + } + + public int getMaximumActiveSessionPerConnection() { + return maximumActiveSessionPerConnection; } /** * Sets the maximum number of active sessions per connection */ - public void setMaximumActive(int maximumActive) { - this.maximumActive = maximumActive; + public void setMaximumActiveSessionPerConnection(int maximumActiveSessionPerConnection) { + this.maximumActiveSessionPerConnection = maximumActiveSessionPerConnection; } /** @@ -242,10 +258,10 @@ public class PooledConnectionFactory implements ConnectionFactory, Service { */ protected ObjectPoolFactory createPoolFactory() { if (blockIfSessionPoolIsFull) { - return new GenericObjectPoolFactory(null, maximumActive); + return new GenericObjectPoolFactory(null, maximumActiveSessionPerConnection); } else { return new GenericObjectPoolFactory(null, - maximumActive, + maximumActiveSessionPerConnection, GenericObjectPool.WHEN_EXHAUSTED_FAIL, GenericObjectPool.DEFAULT_MAX_WAIT); } diff --git a/activemq-pool/src/test/java/org/apache/activemq/pool/PooledConnectionFactoryMaximumActiveTest.java b/activemq-pool/src/test/java/org/apache/activemq/pool/PooledConnectionFactoryMaximumActiveTest.java index 38a9f784f3..bc1b9c219d 100644 --- a/activemq-pool/src/test/java/org/apache/activemq/pool/PooledConnectionFactoryMaximumActiveTest.java +++ b/activemq-pool/src/test/java/org/apache/activemq/pool/PooledConnectionFactoryMaximumActiveTest.java @@ -91,7 +91,7 @@ public class PooledConnectionFactoryMaximumActiveTest extends TestCase ActiveMQConnectionFactory amq = new ActiveMQConnectionFactory("vm://broker1?marshal=false&broker.persistent=false"); PooledConnectionFactory cf = new PooledConnectionFactory(amq); cf.setMaxConnections(3); - cf.setMaximumActive(1); + cf.setMaximumActiveSessionPerConnection(1); cf.setBlockIfSessionPoolIsFull(true); conn = cf.createConnection(); diff --git a/activemq-pool/src/test/java/org/apache/activemq/pool/PooledConnectionFactoryTest.java b/activemq-pool/src/test/java/org/apache/activemq/pool/PooledConnectionFactoryTest.java index ef5b9328bf..2fc5b0c667 100644 --- a/activemq-pool/src/test/java/org/apache/activemq/pool/PooledConnectionFactoryTest.java +++ b/activemq-pool/src/test/java/org/apache/activemq/pool/PooledConnectionFactoryTest.java @@ -109,7 +109,7 @@ class TestRunner implements Callable { ActiveMQConnectionFactory amq = new ActiveMQConnectionFactory("vm://broker1?marshal=false&broker.persistent=false"); PooledConnectionFactory cf = new PooledConnectionFactory(amq); cf.setMaxConnections(3); - cf.setMaximumActive(1); + cf.setMaximumActiveSessionPerConnection(1); cf.setBlockIfSessionPoolIsFull(false); conn = cf.createConnection();