AMQ-4004: The option maximumActive has been name a more descriptive name to not confuse end users. The old name is kept but is @deprecated to be backwards compatible.

git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@1378859 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Claus Ibsen 2012-08-30 08:54:15 +00:00
parent 8fc47c6abf
commit dd2556bc91
4 changed files with 32 additions and 11 deletions

View File

@ -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()));
}

View File

@ -63,7 +63,7 @@ public class PooledConnectionFactory implements ConnectionFactory, Service {
private ConnectionFactory connectionFactory;
private final Map<ConnectionKey, LinkedList<ConnectionPool>> cache = new HashMap<ConnectionKey, LinkedList<ConnectionPool>>();
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);
}

View File

@ -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();

View File

@ -109,7 +109,7 @@ class TestRunner implements Callable<Boolean> {
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();