Disabling JMX for the Commons Pool implementation inside of
PooledConnectionFactory.  In the future if we want JMX we should
enable our own JMX stats that are independent of Commons Pool.
This commit is contained in:
Christopher L. Shannon (cshannon) 2015-10-01 18:08:37 +00:00
parent 450a5226e0
commit 7c7c505057
2 changed files with 8 additions and 6 deletions

View File

@ -29,13 +29,11 @@ import javax.jms.Session;
import javax.jms.TemporaryQueue;
import javax.jms.TemporaryTopic;
import org.apache.commons.pool2.BasePooledObjectFactory;
import org.apache.commons.pool2.KeyedObjectPool;
import org.apache.commons.pool2.KeyedPooledObjectFactory;
import org.apache.commons.pool2.PooledObject;
import org.apache.commons.pool2.impl.DefaultPooledObject;
import org.apache.commons.pool2.impl.GenericKeyedObjectPool;
import org.apache.commons.pool2.impl.GenericObjectPool;
import org.apache.commons.pool2.impl.GenericKeyedObjectPoolConfig;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -66,7 +64,8 @@ public class ConnectionPool implements ExceptionListener {
private ExceptionListener parentExceptionListener;
public ConnectionPool(Connection connection) {
final GenericKeyedObjectPoolConfig poolConfig = new GenericKeyedObjectPoolConfig();
poolConfig.setJmxEnabled(false);
this.connection = wrap(connection);
// Create our internal Pool of session instances.
@ -95,7 +94,7 @@ public class ConnectionPool implements ExceptionListener {
@Override
public void passivateObject(SessionKey sessionKey, PooledObject<SessionHolder> pooledObject) throws Exception {
}
}
}, poolConfig
);
}

View File

@ -32,6 +32,7 @@ import org.apache.commons.pool2.KeyedPooledObjectFactory;
import org.apache.commons.pool2.PooledObject;
import org.apache.commons.pool2.impl.DefaultPooledObject;
import org.apache.commons.pool2.impl.GenericKeyedObjectPool;
import org.apache.commons.pool2.impl.GenericKeyedObjectPoolConfig;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -86,6 +87,8 @@ public class PooledConnectionFactory implements ConnectionFactory, QueueConnecti
public void initConnectionsPool() {
if (this.connectionsPool == null) {
final GenericKeyedObjectPoolConfig poolConfig = new GenericKeyedObjectPoolConfig();
poolConfig.setJmxEnabled(false);
this.connectionsPool = new GenericKeyedObjectPool<ConnectionKey, ConnectionPool>(
new KeyedPooledObjectFactory<ConnectionKey, ConnectionPool>() {
@Override
@ -147,7 +150,7 @@ public class PooledConnectionFactory implements ConnectionFactory, QueueConnecti
public void passivateObject(ConnectionKey connectionKey, PooledObject<ConnectionPool> pooledObject) throws Exception {
}
});
}, poolConfig);
// Set max idle (not max active) since our connections always idle in the pool.
this.connectionsPool.setMaxIdlePerKey(1);