[jboss-svn-commits] JBL Code SVN: r27118 - in labs/jbossesb/trunk/product: samples/quickstarts/https_2way_ssl and 1 other directory.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Wed Jun 24 11:51:31 EDT 2009
Author: tfennelly
Date: 2009-06-24 11:51:30 -0400 (Wed, 24 Jun 2009)
New Revision: 27118
Modified:
labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/http/configurators/Connection.java
labs/jbossesb/trunk/product/samples/quickstarts/https_2way_ssl/HttpRouter-localhost-https-9433.properties
Log:
https://jira.jboss.org/jira/browse/JBESB-2548
HttpClientFactory not configuring the "max-connections-per-host" on the connection manager
Modified: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/http/configurators/Connection.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/http/configurators/Connection.java 2009-06-24 14:51:58 UTC (rev 27117)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/http/configurators/Connection.java 2009-06-24 15:51:30 UTC (rev 27118)
@@ -52,9 +52,20 @@
/**
* HTTP Connection configurator.
* <p/>
+ * This {@link Configurator} is always applied to HttpClient instances created by the
+ * {@link org.jboss.soa.esb.http.HttpClientFactory}. Of course, if you wish to make the
+ * connection configurations in a different way, you can always create a custom {@link Configurator}
+ * that creates and attches a different {@link HttpConnectionManager} instance that has differnt
+ * configurations.
+ * <p/>
* Properties:
* <ul>
- * <li><b>max-total-connections</b>: Maximum total number of connection for the HttpClient.</li>
+ * <li><b>max-total-connections</b>: Maximum total number of connection for the HttpClient instance.</li>
+ * <li><b>max-connections-per-host</b>: Maximum connection per target host for the HttpClient instance. Note that
+ * the default value for this configuration is 2. So, configuring the "max-total-connections" property
+ * without also configuring this property will have little effect on performance for a single host
+ * because it will only ever open a max of 2 connections (as per the default).
+ * </li>
* </ul>
* <p/>
*
@@ -67,21 +78,45 @@
* Max total connections.
*/
public static final String MAX_TOTAL_CONNECTIONS = "max-total-connections";
+ /**
+ * Max connections per host.
+ */
+ public static final String MAX_CONNECTIONS_PER_HOST = "max-connections-per-host";
public void configure(HttpClient httpClient, Properties properties) throws ConfigurationException {
final HttpConnectionManager connectionManager = new MultiThreadedHttpConnectionManager() ;
final String maxTotalConnections = properties.getProperty(MAX_TOTAL_CONNECTIONS) ;
+ final String maxConnectionsPerHost = properties.getProperty(MAX_CONNECTIONS_PER_HOST) ;
if (maxTotalConnections != null) {
- final HttpConnectionManagerParams params = new HttpConnectionManagerParams() ;
+ final HttpConnectionManagerParams params = getConnectionManagerParams(connectionManager);
try {
- params.setMaxTotalConnections(Integer.parseInt(maxTotalConnections)) ;
+ params.setMaxTotalConnections(Integer.parseInt(maxTotalConnections.trim())) ;
} catch (final NumberFormatException nfe) {
throw new ConfigurationException("Invalid " + MAX_TOTAL_CONNECTIONS + " property: " + maxTotalConnections) ;
}
- connectionManager.setParams(params) ;
}
+ if (maxConnectionsPerHost != null) {
+ final HttpConnectionManagerParams params = getConnectionManagerParams(connectionManager);
+ try {
+ params.setMaxConnectionsPerHost(httpClient.getHostConfiguration(), Integer.parseInt(maxConnectionsPerHost.trim()));
+ } catch (final NumberFormatException nfe) {
+ throw new ConfigurationException("Invalid " + MAX_CONNECTIONS_PER_HOST + " property: " + maxConnectionsPerHost) ;
+ }
+ }
+
httpClient.setHttpConnectionManager(connectionManager);
}
+
+ private HttpConnectionManagerParams getConnectionManagerParams(HttpConnectionManager connectionManager) {
+ HttpConnectionManagerParams params = connectionManager.getParams();
+
+ if(params == null) {
+ params = new HttpConnectionManagerParams();
+ connectionManager.setParams(params) ;
+ }
+
+ return params;
+ }
}
\ No newline at end of file
Modified: labs/jbossesb/trunk/product/samples/quickstarts/https_2way_ssl/HttpRouter-localhost-https-9433.properties
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/https_2way_ssl/HttpRouter-localhost-https-9433.properties 2009-06-24 14:51:58 UTC (rev 27117)
+++ labs/jbossesb/trunk/product/samples/quickstarts/https_2way_ssl/HttpRouter-localhost-https-9433.properties 2009-06-24 15:51:30 UTC (rev 27118)
@@ -13,3 +13,6 @@
keystore-passw=https_2way_ssl_pass
truststore=@keystore@
truststore-passw=https_2way_ssl_pass
+
+# Connection config
+max-connections-per-host=5
More information about the jboss-svn-commits
mailing list