[jboss-svn-commits] JBL Code SVN: r13038 - in labs/jbossesb/trunk/product: install/conf and 2 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Tue Jul 3 10:18:10 EDT 2007
Author: mark.little at jboss.com
Date: 2007-07-03 10:18:09 -0400 (Tue, 03 Jul 2007)
New Revision: 13038
Modified:
labs/jbossesb/trunk/product/docs/AdministrationGuide.odt
labs/jbossesb/trunk/product/install/conf/jbossesb-properties.xml
labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/rosetta/pooling/JmsConnectionPool.java
labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/common/Environment.java
Log:
http://jira.jboss.com/jira/browse/JBESB-579
Modified: labs/jbossesb/trunk/product/docs/AdministrationGuide.odt
===================================================================
(Binary files differ)
Modified: labs/jbossesb/trunk/product/install/conf/jbossesb-properties.xml
===================================================================
--- labs/jbossesb/trunk/product/install/conf/jbossesb-properties.xml 2007-07-03 13:39:43 UTC (rev 13037)
+++ labs/jbossesb/trunk/product/install/conf/jbossesb-properties.xml 2007-07-03 14:18:09 UTC (rev 13038)
@@ -53,6 +53,8 @@
<property name="org.jboss.soa.esb.mail.smtp.port" value="25"/>
<property name="org.jboss.soa.esb.ftp.localdir" value="/tmp"/>
<property name="org.jboss.soa.esb.ftp.remotedir" value="/tmp"/>
+ <property name="org.jboss.soa.esb.jms.connectionPool" value="20"/>
+ <property name="org.jboss.soa.esb.jms.sessionSleep" value="30"/>
</properties>
<properties name="connection">
<property name="min-pool-size" value="5"/>
Modified: labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/rosetta/pooling/JmsConnectionPool.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/rosetta/pooling/JmsConnectionPool.java 2007-07-03 13:39:43 UTC (rev 13037)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/rosetta/pooling/JmsConnectionPool.java 2007-07-03 14:18:09 UTC (rev 13038)
@@ -40,8 +40,12 @@
import org.apache.log4j.Logger;
import org.jboss.soa.esb.addressing.eprs.JMSEpr;
+import org.jboss.soa.esb.common.Environment;
+import org.jboss.soa.esb.common.ModulePropertyManager;
import org.jboss.soa.esb.helpers.NamingContext;
+import com.arjuna.common.util.propertyservice.PropertyManager;
+
/**
* Interface that needs to be implemented to provide pool of connections.
* @see DefaultConnectionPoolImpl
@@ -51,8 +55,16 @@
*/
public class JmsConnectionPool
{
+ private static final int DEFAULT_POOL_SIZE = 20;
+ private static final int DEFAULT_SLEEP = 30;
+
+ private static int CONFIGURED_POOL_SIZE = DEFAULT_POOL_SIZE;
+ private static int CONFIGURED_SLEEP = DEFAULT_SLEEP;
+
/** Maximum number of Sessions that will be created in this pool */
- private int MAX_SESSIONS=20; //TODO Make this manageable
+ private int MAX_SESSIONS = DEFAULT_POOL_SIZE; //TODO Make this manageable
+ /** Time to sleep when trying to get a session. */
+ private int SLEEP_TIME = DEFAULT_SLEEP;
/** Number of free sessions in the pool that can be given out */
private ArrayList<Session> freeSessions = new ArrayList<Session>();
/** Number of session that are currently in use */
@@ -71,7 +83,15 @@
*/
public JmsConnectionPool(Map<String, String> poolKey)
{
+ this(poolKey, JmsConnectionPool.CONFIGURED_POOL_SIZE, JmsConnectionPool.CONFIGURED_SLEEP);
+ }
+
+ public JmsConnectionPool(Map<String, String> poolKey, int poolSize, int sleepTime)
+ {
this.poolKey = poolKey;
+
+ MAX_SESSIONS = poolSize;
+ SLEEP_TIME = sleepTime;
}
/**
@@ -154,9 +174,9 @@
session = freeSessions.remove(freeSessions.size()-1);
inUseSessions.add(session);
} else {
- if (waitInSeconds++ > 30) {
-// We'll give up after not be able to get a session for 30 seconds.
- throw new ConnectionException("Could not obtain a JMS connection from the pool after 30s.");
+ if (waitInSeconds++ > SLEEP_TIME) {
+// We'll give up after not be able to get a session for SLEEP_TIME seconds.
+ throw new ConnectionException("Could not obtain a JMS connection from the pool after "+SLEEP_TIME+"s.");
}
//Add a connection if we can
if (inUseSessions.size()<MAX_SESSIONS) {
@@ -165,7 +185,7 @@
try {
//wait one second and try again.
logger.info("The connection pool was exhausted. Waiting 1 second before trying again..");
- wait(1000);
+ wait(1000); // TODO magic number!
} catch (Exception e) {
e.printStackTrace();
}
@@ -241,4 +261,36 @@
public int getSessionsInPool() {
return freeSessions.size() + inUseSessions.size();
}
+
+ static
+ {
+ PropertyManager prop = ModulePropertyManager.getPropertyManager(ModulePropertyManager.TRANSPORTS_MODULE);
+ String value = prop.getProperty(Environment.JMS_CONNECTION_POOL_SIZE);
+
+ if (value != null)
+ {
+ try
+ {
+ CONFIGURED_POOL_SIZE = Integer.parseInt(value);
+ }
+ catch (NumberFormatException ex)
+ {
+ ex.printStackTrace();
+ }
+ }
+
+ value = prop.getProperty(Environment.JMS_SESSION_SLEEP);
+
+ if (value != null)
+ {
+ try
+ {
+ CONFIGURED_SLEEP = Integer.parseInt(value);
+ }
+ catch (NumberFormatException ex)
+ {
+ ex.printStackTrace();
+ }
+ }
+ }
}
Modified: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/common/Environment.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/common/Environment.java 2007-07-03 13:39:43 UTC (rev 13037)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/common/Environment.java 2007-07-03 14:18:09 UTC (rev 13038)
@@ -45,6 +45,9 @@
public static final String FTP_LOCALDIR = "org.jboss.soa.esb.ftp.localdir";
public static final String FTP_REMOTEDIR = "org.jboss.soa.esb.ftp.remotedir";
+ public static final String JMS_CONNECTION_POOL_SIZE = "org.jboss.soa.esb.jms.connectionPool";
+ public static final String JMS_SESSION_SLEEP = "org.jboss.soa.esb.jms.sessionSleep";
+
/*
* Code properties
*/
More information about the jboss-svn-commits
mailing list