apply fix for: https://issues.apache.org/jira/browse/AMQ-3482 to return default behavior to blocking.

git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@1164058 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Timothy A. Bish 2011-09-01 13:02:28 +00:00
parent 588a3c3594
commit 5ac1540c63
2 changed files with 115 additions and 127 deletions

View File

@ -66,7 +66,7 @@ public class PooledConnectionFactory implements ConnectionFactory, Service {
private int maximumActive = 500;
private int maxConnections = 1;
private int idleTimeout = 30 * 1000;
private boolean blockIfSessionPoolIsFull = false;
private boolean blockIfSessionPoolIsFull = true;
private AtomicBoolean stopped = new AtomicBoolean(false);
private long expiryTimeout = 0l;
@ -197,20 +197,16 @@ public class PooledConnectionFactory implements ConnectionFactory, Service {
}
/**
* Controls the behavior of the internal session pool.
* By default the call to Connection.getSession() will
* return a JMSException if the session pool is full.
* If the argument true is given, it will change the
* default behavior and instead the call to getSession()
* will block until a session is available in the pool, which
* used to be the default behavior in ActiveMQ versions < 5.6.
* Controls the behavior of the internal session pool. By default the call to
* Connection.getSession() will block if the session pool is full. If the
* argument false is given, it will change the default behavior and instead the
* call to getSession() will throw a JMSException.
*
* The size of the session pool is controlled by the @see #maximumActive
* property.
*
* @param block - if true, the call to getSession() blocks if the pool
* is full until a session object is available.
* defaults to false.
* @param block - if true, the call to getSession() blocks if the pool is full
* until a session object is available. defaults to true.
*/
public void setBlockIfSessionPoolIsFull(boolean block) {
this.blockIfSessionPoolIsFull = block;

View File

@ -54,12 +54,7 @@ public class PooledConnectionFactoryTest extends TestCase
/**
* Tests the behavior of the sessionPool of the PooledConnectionFactory
* when maximum number of sessions are reached. In older versions the call to
* Connection.createSession() would simply block indefinitely if the maximum
* number of sessions got reached (controled by
* PooledConnectionFactory.setMaximumActive()).
* Rather than blocking the entire thread, it should raise an exception
* instead.
* when maximum number of sessions are reached.
*/
public void testApp() throws Exception
{
@ -103,9 +98,6 @@ class TestRunner implements Callable<Boolean> {
PooledConnectionFactory cf = new PooledConnectionFactory(amq);
cf.setMaxConnections(3);
cf.setMaximumActive(1);
// default should be false already but lets make sure a change to the default
// setting does not make this test fail.
cf.setBlockIfSessionPoolIsFull(false);
conn = cf.createConnection();