[
https://issues.apache.org/activemq/browse/SMXCOMP-722?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Ioannis Canellos updated SMXCOMP-722:
-------------------------------------
Attachment: patchfile.txt
The patch
> Http Component & Http Provider Endpoint do not offer a way to change the
> Jetty expiration time.
> -----------------------------------------------------------------------------------------------
>
> Key: SMXCOMP-722
> URL: https://issues.apache.org/activemq/browse/SMXCOMP-722
> Project: ServiceMix Components
> Issue Type: Improvement
> Components: servicemix-http
> Affects Versions: servicemix-http-2008.01, servicemix-http-2009.01,
> servicemix-http-2009.02
> Reporter: Ioannis Canellos
> Fix For: servicemix-bean-2010.01
>
> Attachments: patchfile.txt
>
>
> A couple of weeks ago I submitted a patch that added support for Jetty Client
> Expiration (read timeout) on the Http Provider Endpoint
> :https://issues.apache.org/activemq/browse/SMXCOMP-717
> In most cases it is useful to be able to change that on the component and the
> provider when using jettyClientPerProvider.
> I am attaching a patch that adds a new property called providerExpirationTime
> on HttpConfiguration and HttpProviderEndpoint.
> The patch also updates:
> The HttpComponent to save / load the property from the components.property
> file.
> The HttpProviderEndpoint so that it is possible to set this property
> explicitly per provider.
> Finally, it adds a new unit test that tests the above using the following
> scenarios:
> test expiration using providerExpirationTime set on HttpComponent
> configuration.
> test expiration using providerExpirationTime set on the provider.
> test no expiration.
> Index:
> src/test/java/org/apache/servicemix/http/endpoints/HttpProviderExpirationTest.java
> ===================================================================
> ---
> src/test/java/org/apache/servicemix/http/endpoints/HttpProviderExpirationTest.java
> (revision 0)
> +++
> src/test/java/org/apache/servicemix/http/endpoints/HttpProviderExpirationTest.java
> (revision 0)
> @@ -0,0 +1,206 @@
> +/*
> + * Copyright 2010 iocanel.
> + *
> + * Licensed under the Apache License, Version 2.0 (the "License");
> + * you may not use this file except in compliance with the License.
> + * You may obtain a copy of the License at
> + *
> + * http://www.apache.org/licenses/LICENSE-2.0
> + *
> + * Unless required by applicable law or agreed to in writing, software
> + * distributed under the License is distributed on an "AS IS" BASIS,
> + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
> + * See the License for the specific language governing permissions and
> + * limitations under the License.
> + * under the License.
> + */
> +package org.apache.servicemix.http.endpoints;
> +
> +import java.net.URI;
> +
> +import javax.jbi.messaging.InOut;
> +import javax.jbi.messaging.MessageExchange;
> +import javax.jbi.messaging.NormalizedMessage;
> +import javax.servlet.http.HttpServletRequest;
> +import javax.servlet.http.HttpServletResponse;
> +import javax.xml.namespace.QName;
> +
> +import junit.framework.TestCase;
> +
> +import org.apache.activemq.broker.BrokerService;
> +import org.apache.servicemix.client.DefaultServiceMixClient;
> +import org.apache.servicemix.client.Destination;
> +import org.apache.servicemix.components.util.EchoComponent;
> +import org.apache.servicemix.http.HttpComponent;
> +import org.apache.servicemix.http.HttpEndpointType;
> +import org.apache.servicemix.jbi.container.JBIContainer;
> +import org.apache.servicemix.jbi.jaxp.StringSource;
> +import org.apache.servicemix.jbi.nmr.flow.Flow;
> +import org.apache.servicemix.jbi.nmr.flow.seda.SedaFlow;
> +
> +/**
> + *
> + * @author ioannis canellos
> + */
> +public class HttpProviderExpirationTest extends TestCase {
> +
> + private JBIContainer jbi;
> + private BrokerService broker;
> +
> + protected void setUp() throws Exception {
> + broker = new BrokerService();
> + broker.setUseJmx(false);
> + broker.setPersistent(false);
> + broker.addConnector("tcp://localhost:61616");
> + broker.start();
> +
> +
> + jbi = new JBIContainer();
> + jbi.setFlows(new Flow[]{new SedaFlow()});
> + jbi.setEmbedded(true);
> + jbi.setUseMBeanServer(false);
> + jbi.setCreateMBeanServer(false);
> + jbi.setAutoEnlistInTransaction(true);
> + jbi.init();
> + jbi.start();
> + }
> +
> + protected void tearDown() throws Exception {
> + jbi.shutDown();
> + broker.stop();
> + }
> +
> + public void testExpirationOnComponent() throws Exception {
> + EchoComponent echo = new EchoComponent();
> + echo.setService(new QName("urn:test", "echo"));
> + echo.setEndpoint("echo");
> + jbi.activateComponent(echo, "echo");
> +
> + HttpProviderEndpoint provider = new HttpProviderEndpoint();
> + provider.setService(new QName("urn:test", "provider"));
> + provider.setEndpoint("provider");
> + provider.setLocationURI("http://localhost:8192/expiration/");
> + provider.setProviderExpirationTime(100000);
> +
> + HttpConsumerEndpoint consumer = new HttpConsumerEndpoint();
> + consumer.setService(new QName("urn:test", "consumer"));
> + consumer.setEndpoint("consumer");
> + consumer.setTargetService(new QName("urn:test", "echo"));
> + consumer.setLocationURI("http://localhost:8192/expiration/");
> +
> consumer.setDefaultMep(URI.create("http://www.w3.org/2004/08/wsdl/in-out"));
> + consumer.setMarshaler(new DefaultHttpConsumerMarshaler() {
> +
> + @Override
> + public void sendOut(MessageExchange exchange, NormalizedMessage
> outMsg, HttpServletRequest request, HttpServletResponse response) throws
> Exception {
> + Thread.sleep(10000);
> + super.sendOut(exchange, outMsg, request, response);
> + }
> + });
> +
> +
> + HttpComponent http = new HttpComponent();
> + http.getConfiguration().setProviderExpirationTime(10);
> + http.setEndpoints(new HttpEndpointType[]{provider, consumer});
> + jbi.activateComponent(http, "http");
> +
> + DefaultServiceMixClient client = new DefaultServiceMixClient(jbi);
> + Destination d =
> client.createDestination("service:urn:test:provider");
> + InOut me = d.createInOutExchange();
> + me.getInMessage().setContent(new
> StringSource("<hello>world</hello>"));
> +
> + boolean ok = client.sendSync(me);
> + Exception exception = me.getError();
> + assertTrue(exception != null);
> + }
> +
> + public void testExpirationOnProvider() throws Exception {
> + EchoComponent echo = new EchoComponent();
> + echo.setService(new QName("urn:test", "echo"));
> + echo.setEndpoint("echo");
> + jbi.activateComponent(echo, "echo");
> +
> + HttpProviderEndpoint provider = new HttpProviderEndpoint();
> + provider.setService(new QName("urn:test", "provider"));
> + provider.setEndpoint("provider");
> + provider.setLocationURI("http://localhost:8192/expiration/");
> + provider.setProviderExpirationTime(10);
> +
> + HttpConsumerEndpoint consumer = new HttpConsumerEndpoint();
> + consumer.setService(new QName("urn:test", "consumer"));
> + consumer.setEndpoint("consumer");
> + consumer.setTargetService(new QName("urn:test", "echo"));
> + consumer.setLocationURI("http://localhost:8192/expiration/");
> +
> consumer.setDefaultMep(URI.create("http://www.w3.org/2004/08/wsdl/in-out"));
> + consumer.setMarshaler(new DefaultHttpConsumerMarshaler() {
> +
> + @Override
> + public void sendOut(MessageExchange exchange, NormalizedMessage
> outMsg, HttpServletRequest request, HttpServletResponse response) throws
> Exception {
> + Thread.sleep(10000);
> + super.sendOut(exchange, outMsg, request, response);
> + }
> + });
> +
> +
> + HttpComponent http = new HttpComponent();
> + //To avoid adding delaying mechanisms we are using an extremly low
> expiration time.
> + http.getConfiguration().setProviderExpirationTime(300000);
> + http.getConfiguration().setJettyClientPerProvider(true);
> + http.setEndpoints(new HttpEndpointType[]{provider, consumer});
> + jbi.activateComponent(http, "http");
> +
> + DefaultServiceMixClient client = new DefaultServiceMixClient(jbi);
> + Destination d =
> client.createDestination("service:urn:test:provider");
> + InOut me = d.createInOutExchange();
> + me.getInMessage().setContent(new
> StringSource("<hello>world</hello>"));
> +
> + boolean ok = client.sendSync(me);
> + Exception exception = me.getError();
> + assertTrue(exception != null);
> + }
> +
> + public void testNoExpiration() throws Exception {
> + EchoComponent echo = new EchoComponent();
> + echo.setService(new QName("urn:test", "echo"));
> + echo.setEndpoint("echo");
> + jbi.activateComponent(echo, "echo");
> +
> + HttpProviderEndpoint provider = new HttpProviderEndpoint();
> + provider.setService(new QName("urn:test", "provider"));
> + provider.setEndpoint("provider");
> + provider.setLocationURI("http://localhost:8192/expiration/");
> + provider.setProviderExpirationTime(300000);
> +
> + HttpConsumerEndpoint consumer = new HttpConsumerEndpoint();
> + consumer.setService(new QName("urn:test", "consumer"));
> + consumer.setEndpoint("consumer");
> + consumer.setTargetService(new QName("urn:test", "echo"));
> + consumer.setLocationURI("http://localhost:8192/expiration/");
> +
> consumer.setDefaultMep(URI.create("http://www.w3.org/2004/08/wsdl/in-out"));
> + consumer.setMarshaler(new DefaultHttpConsumerMarshaler() {
> +
> + @Override
> + public void sendOut(MessageExchange exchange, NormalizedMessage
> outMsg, HttpServletRequest request, HttpServletResponse response) throws
> Exception {
> + Thread.sleep(10000);
> + super.sendOut(exchange, outMsg, request, response);
> + }
> + });
> +
> +
> + HttpComponent http = new HttpComponent();
> + //To avoid adding delaying mechanisms we are using an extremly low
> expiration time.
> + http.getConfiguration().setProviderExpirationTime(300000);
> + http.getConfiguration().setJettyClientPerProvider(true);
> + http.setEndpoints(new HttpEndpointType[]{provider, consumer});
> + jbi.activateComponent(http, "http");
> +
> + DefaultServiceMixClient client = new DefaultServiceMixClient(jbi);
> + Destination d =
> client.createDestination("service:urn:test:provider");
> + InOut me = d.createInOutExchange();
> + me.getInMessage().setContent(new
> StringSource("<hello>world</hello>"));
> +
> + boolean ok = client.sendSync(me);
> + Exception exception = me.getError();
> + assertTrue(exception == null);
> + client.done(me);
> + }
> +}
> Index: src/test/java/org/apache/servicemix/http/HttpTxTest.java
> ===================================================================
> --- src/test/java/org/apache/servicemix/http/HttpTxTest.java (revision
> 921248)
> +++ src/test/java/org/apache/servicemix/http/HttpTxTest.java (working copy)
> @@ -36,6 +36,7 @@
> import org.apache.servicemix.tck.ExchangeCompletedListener;
> import org.jencks.GeronimoPlatformTransactionManager;
>
> +
> public class HttpTxTest extends TestCase {
>
> private ExchangeCompletedListener listener;
> Property changes on: src/main/java/org/apache/servicemix/http
> ___________________________________________________________________
> Added: svn:ignore
> + .HttpConfiguration.java.swp
> Index: src/main/java/org/apache/servicemix/http/HttpComponent.java
> ===================================================================
> --- src/main/java/org/apache/servicemix/http/HttpComponent.java
> (revision 921248)
> +++ src/main/java/org/apache/servicemix/http/HttpComponent.java
> (working copy)
> @@ -178,6 +178,7 @@
> btp.setMaxThreads(getConfiguration().getJettyClientThreadPoolSize());
> tempClient.setThreadPool(btp);
>
> tempClient.setConnectorType(org.mortbay.jetty.client.HttpClient.CONNECTOR_SELECT_CHANNEL);
> +
> tempClient.setTimeout(getConfiguration().getProviderExpirationTime());
> tempClient.start();
> return tempClient;
> }
> Index: src/main/java/org/apache/servicemix/http/HttpConfiguration.java
> ===================================================================
> --- src/main/java/org/apache/servicemix/http/HttpConfiguration.java
> (revision 921248)
> +++ src/main/java/org/apache/servicemix/http/HttpConfiguration.java
> (working copy)
> @@ -113,6 +113,11 @@
> * servicemix is 60000msec)
> */
> private int consumerProcessorSuspendTime = 60000;
> +
> + /***
> + * HttpProvider endpoint expiration time.
> + */
> + private int providerExpirationTime = 60000;
>
> /**
> * Number of times a given HTTP request will be tried until successful.
> If
> @@ -525,7 +530,29 @@
> save();
> }
>
> +
> + /***
> + * Gets the number of milliseconds that the provider will wait for a
> response before expiring.
> + * @return an int representing the ammout of time the provider will wait
> for a response before expiring.
> + */
> + public int getProviderExpirationTime() {
> + return providerExpirationTime;
> + }
> +
> /**
> + * Sets the number of milliseconds the provider will wait for a response
> (read timeout).
> + * The default default value for Jetty is 300000.
> + *
> + * @param providerExpirationTime an int representing the number of
> milliseconds the Jetty will wait for a response.
> + * @org.apache.xbean.Property description="the number of miliseconds
> Jetty will susspend the processing of a request. The default is 60000."
> + */
> + public void setProviderExpirationTime(int providerExpirationTime) {
> + this.providerExpirationTime = providerExpirationTime;
> + }
> +
> +
> +
> + /**
> * Gets the number of times a request will be tried before an error is
> * created.
> *
> @@ -621,6 +648,7 @@
> setProperty(componentName + ".connectorMaxIdleTime",
> Integer.toString(connectorMaxIdleTime));
> setProperty(componentName + ".consumerProcessorSuspendTime", Integer
> .toString(consumerProcessorSuspendTime));
> + setProperty(componentName + ".providerExpirationTime",
> Integer.toString(providerExpirationTime));
> setProperty(componentName + ".retryCount",
> Integer.toString(retryCount));
> setProperty(componentName + ".proxyHost", proxyHost);
> setProperty(componentName + ".proxyPort",
> Integer.toString(proxyPort));
> @@ -719,6 +747,10 @@
> consumerProcessorSuspendTime = Integer.parseInt(properties
> .getProperty(componentName +
> ".consumerProcessorSuspendTime"));
> }
> + if (properties.getProperty(componentName +
> ".providerExpirationTime") != null) {
> + providerExpirationTime = Integer.parseInt(properties
> + .getProperty(componentName + ".providerExpirationTime"));
> + }
> if (properties.getProperty(componentName + ".retryCount") != null) {
> retryCount =
> Integer.parseInt(properties.getProperty(componentName + ".retryCount"));
> }
> Index: src/main/java/org/apache/servicemix/http/HttpConfigurationMBean.java
> ===================================================================
> --- src/main/java/org/apache/servicemix/http/HttpConfigurationMBean.java
> (revision 921248)
> +++ src/main/java/org/apache/servicemix/http/HttpConfigurationMBean.java
> (working copy)
> @@ -65,7 +65,11 @@
> int getConsumerProcessorSuspendTime();
>
> void setConsumerProcessorSuspendTime(int consumerProcessorSuspendTime);
> +
> + int getProviderExpirationTime();
>
> + void setProviderExpirationTime(int providerExpirationTime);
> +
> int getRetryCount();
>
> void setRetryCount(int retryCount);
> Index:
> src/main/java/org/apache/servicemix/http/endpoints/HttpProviderEndpoint.java
> ===================================================================
> ---
> src/main/java/org/apache/servicemix/http/endpoints/HttpProviderEndpoint.java
> (revision 921248)
> +++
> src/main/java/org/apache/servicemix/http/endpoints/HttpProviderEndpoint.java
> (working copy)
> @@ -63,6 +63,7 @@
> private HttpProviderMarshaler marshaler;
> private String locationURI;
> private int clientSoTimeout = 60000;
> + private int providerExpirationTime = 300000;
> private HttpClient jettyClient;
> private boolean ownClient = false;
>
> @@ -294,6 +295,7 @@
> }
> }
> jettyClient.setSoTimeout(getClientSoTimeout());
> + jettyClient.setTimeout(getProviderExpirationTime());
> jettyClient.start();
> } else {
> ownClient = false;
> @@ -323,6 +325,20 @@
> this.clientSoTimeout = clientTimeout;
> }
>
> + public int getProviderExpirationTime() {
> + return providerExpirationTime;
> + }
> +
> + /***
> + * Sets the number of milliseconds the endpoint will wait to read the
> response. The default value is 300000.
> + *
> + * @param providerExpirationTime an int specifying the number of
> milliseconds to wait for a response before expiring.
> + * @org.apache.xbean.Property description="the number of milliseconds to
> wait for a response before expiring."
> + */
> + public void setProviderExpirationTime(int providerExpirationTime) {
> + this.providerExpirationTime = providerExpirationTime;
> + }
> +
> public void validate() throws DeploymentException {
> super.validate();
> if (marshaler == null) {
> Index: src/main/resources/META-INF/spring/servicemix-http.xml
> ===================================================================
> --- src/main/resources/META-INF/spring/servicemix-http.xml (revision
> 921248)
> +++ src/main/resources/META-INF/spring/servicemix-http.xml (working copy)
> @@ -45,6 +45,7 @@
> <bean id="servicemix-http-configuration"
> class="org.apache.servicemix.http.HttpConfiguration">
> <property name="connectorMaxIdleTime"
> value="${connectorMaxIdleTime}" />
> <property name="consumerProcessorSuspendTime"
> value="${consumerProcessorSuspendTime}" />
> + <property name="providerExpirationTime"
> value="${providerExpirationTime}" />
> <property name="jettyClientThreadPoolSize"
> value="${jettyClientThreadPoolSize}" />
> <property name="jettyConnectorClassName"
> value="${jettyConnectorClassName}" />
> <property name="jettyThreadPoolSize" value="${jettyThreadPoolSize}"
> />
> @@ -92,6 +93,7 @@
> <osgix:cm-properties id="cmProps"
> persistent-id="org.apache.servicemix.components.http">
> <prop key="connectorMaxIdleTime">30000</prop>
> <prop key="consumerProcessorSuspendTime">60000</prop>
> + <prop key="providerExpirationTime">300000</prop>
> <prop key="jettyClientThreadPoolSize">16</prop>
> <prop
> key="jettyConnectorClassName">org.mortbay.jetty.nio.SelectChannelConnector</prop>
> <prop key="jettyThreadPoolSize">255</prop>
> Index:
> src/test/java/org/apache/servicemix/http/endpoints/HttpProviderExpirationTest.java
> ===================================================================
> ---
> src/test/java/org/apache/servicemix/http/endpoints/HttpProviderExpirationTest.java
> (revision 0)
> +++
> src/test/java/org/apache/servicemix/http/endpoints/HttpProviderExpirationTest.java
> (revision 0)
> @@ -0,0 +1,206 @@
> +/*
> + * Copyright 2010 iocanel.
> + *
> + * Licensed under the Apache License, Version 2.0 (the "License");
> + * you may not use this file except in compliance with the License.
> + * You may obtain a copy of the License at
> + *
> + * http://www.apache.org/licenses/LICENSE-2.0
> + *
> + * Unless required by applicable law or agreed to in writing, software
> + * distributed under the License is distributed on an "AS IS" BASIS,
> + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
> + * See the License for the specific language governing permissions and
> + * limitations under the License.
> + * under the License.
> + */
> +package org.apache.servicemix.http.endpoints;
> +
> +import java.net.URI;
> +
> +import javax.jbi.messaging.InOut;
> +import javax.jbi.messaging.MessageExchange;
> +import javax.jbi.messaging.NormalizedMessage;
> +import javax.servlet.http.HttpServletRequest;
> +import javax.servlet.http.HttpServletResponse;
> +import javax.xml.namespace.QName;
> +
> +import junit.framework.TestCase;
> +
> +import org.apache.activemq.broker.BrokerService;
> +import org.apache.servicemix.client.DefaultServiceMixClient;
> +import org.apache.servicemix.client.Destination;
> +import org.apache.servicemix.components.util.EchoComponent;
> +import org.apache.servicemix.http.HttpComponent;
> +import org.apache.servicemix.http.HttpEndpointType;
> +import org.apache.servicemix.jbi.container.JBIContainer;
> +import org.apache.servicemix.jbi.jaxp.StringSource;
> +import org.apache.servicemix.jbi.nmr.flow.Flow;
> +import org.apache.servicemix.jbi.nmr.flow.seda.SedaFlow;
> +
> +/**
> + *
> + * @author ioannis canellos
> + */
> +public class HttpProviderExpirationTest extends TestCase {
> +
> + private JBIContainer jbi;
> + private BrokerService broker;
> +
> + protected void setUp() throws Exception {
> + broker = new BrokerService();
> + broker.setUseJmx(false);
> + broker.setPersistent(false);
> + broker.addConnector("tcp://localhost:61616");
> + broker.start();
> +
> +
> + jbi = new JBIContainer();
> + jbi.setFlows(new Flow[]{new SedaFlow()});
> + jbi.setEmbedded(true);
> + jbi.setUseMBeanServer(false);
> + jbi.setCreateMBeanServer(false);
> + jbi.setAutoEnlistInTransaction(true);
> + jbi.init();
> + jbi.start();
> + }
> +
> + protected void tearDown() throws Exception {
> + jbi.shutDown();
> + broker.stop();
> + }
> +
> + public void testExpirationOnComponent() throws Exception {
> + EchoComponent echo = new EchoComponent();
> + echo.setService(new QName("urn:test", "echo"));
> + echo.setEndpoint("echo");
> + jbi.activateComponent(echo, "echo");
> +
> + HttpProviderEndpoint provider = new HttpProviderEndpoint();
> + provider.setService(new QName("urn:test", "provider"));
> + provider.setEndpoint("provider");
> + provider.setLocationURI("http://localhost:8192/expiration/");
> + provider.setProviderExpirationTime(100000);
> +
> + HttpConsumerEndpoint consumer = new HttpConsumerEndpoint();
> + consumer.setService(new QName("urn:test", "consumer"));
> + consumer.setEndpoint("consumer");
> + consumer.setTargetService(new QName("urn:test", "echo"));
> + consumer.setLocationURI("http://localhost:8192/expiration/");
> +
> consumer.setDefaultMep(URI.create("http://www.w3.org/2004/08/wsdl/in-out"));
> + consumer.setMarshaler(new DefaultHttpConsumerMarshaler() {
> +
> + @Override
> + public void sendOut(MessageExchange exchange, NormalizedMessage
> outMsg, HttpServletRequest request, HttpServletResponse response) throws
> Exception {
> + Thread.sleep(10000);
> + super.sendOut(exchange, outMsg, request, response);
> + }
> + });
> +
> +
> + HttpComponent http = new HttpComponent();
> + http.getConfiguration().setProviderExpirationTime(10);
> + http.setEndpoints(new HttpEndpointType[]{provider, consumer});
> + jbi.activateComponent(http, "http");
> +
> + DefaultServiceMixClient client = new DefaultServiceMixClient(jbi);
> + Destination d =
> client.createDestination("service:urn:test:provider");
> + InOut me = d.createInOutExchange();
> + me.getInMessage().setContent(new
> StringSource("<hello>world</hello>"));
> +
> + boolean ok = client.sendSync(me);
> + Exception exception = me.getError();
> + assertTrue(exception != null);
> + }
> +
> + public void testExpirationOnProvider() throws Exception {
> + EchoComponent echo = new EchoComponent();
> + echo.setService(new QName("urn:test", "echo"));
> + echo.setEndpoint("echo");
> + jbi.activateComponent(echo, "echo");
> +
> + HttpProviderEndpoint provider = new HttpProviderEndpoint();
> + provider.setService(new QName("urn:test", "provider"));
> + provider.setEndpoint("provider");
> + provider.setLocationURI("http://localhost:8192/expiration/");
> + provider.setProviderExpirationTime(10);
> +
> + HttpConsumerEndpoint consumer = new HttpConsumerEndpoint();
> + consumer.setService(new QName("urn:test", "consumer"));
> + consumer.setEndpoint("consumer");
> + consumer.setTargetService(new QName("urn:test", "echo"));
> + consumer.setLocationURI("http://localhost:8192/expiration/");
> +
> consumer.setDefaultMep(URI.create("http://www.w3.org/2004/08/wsdl/in-out"));
> + consumer.setMarshaler(new DefaultHttpConsumerMarshaler() {
> +
> + @Override
> + public void sendOut(MessageExchange exchange, NormalizedMessage
> outMsg, HttpServletRequest request, HttpServletResponse response) throws
> Exception {
> + Thread.sleep(10000);
> + super.sendOut(exchange, outMsg, request, response);
> + }
> + });
> +
> +
> + HttpComponent http = new HttpComponent();
> + //To avoid adding delaying mechanisms we are using an extremly low
> expiration time.
> + http.getConfiguration().setProviderExpirationTime(300000);
> + http.getConfiguration().setJettyClientPerProvider(true);
> + http.setEndpoints(new HttpEndpointType[]{provider, consumer});
> + jbi.activateComponent(http, "http");
> +
> + DefaultServiceMixClient client = new DefaultServiceMixClient(jbi);
> + Destination d =
> client.createDestination("service:urn:test:provider");
> + InOut me = d.createInOutExchange();
> + me.getInMessage().setContent(new
> StringSource("<hello>world</hello>"));
> +
> + boolean ok = client.sendSync(me);
> + Exception exception = me.getError();
> + assertTrue(exception != null);
> + }
> +
> + public void testNoExpiration() throws Exception {
> + EchoComponent echo = new EchoComponent();
> + echo.setService(new QName("urn:test", "echo"));
> + echo.setEndpoint("echo");
> + jbi.activateComponent(echo, "echo");
> +
> + HttpProviderEndpoint provider = new HttpProviderEndpoint();
> + provider.setService(new QName("urn:test", "provider"));
> + provider.setEndpoint("provider");
> + provider.setLocationURI("http://localhost:8192/expiration/");
> + provider.setProviderExpirationTime(300000);
> +
> + HttpConsumerEndpoint consumer = new HttpConsumerEndpoint();
> + consumer.setService(new QName("urn:test", "consumer"));
> + consumer.setEndpoint("consumer");
> + consumer.setTargetService(new QName("urn:test", "echo"));
> + consumer.setLocationURI("http://localhost:8192/expiration/");
> +
> consumer.setDefaultMep(URI.create("http://www.w3.org/2004/08/wsdl/in-out"));
> + consumer.setMarshaler(new DefaultHttpConsumerMarshaler() {
> +
> + @Override
> + public void sendOut(MessageExchange exchange, NormalizedMessage
> outMsg, HttpServletRequest request, HttpServletResponse response) throws
> Exception {
> + Thread.sleep(10000);
> + super.sendOut(exchange, outMsg, request, response);
> + }
> + });
> +
> +
> + HttpComponent http = new HttpComponent();
> + //To avoid adding delaying mechanisms we are using an extremly low
> expiration time.
> + http.getConfiguration().setProviderExpirationTime(300000);
> + http.getConfiguration().setJettyClientPerProvider(true);
> + http.setEndpoints(new HttpEndpointType[]{provider, consumer});
> + jbi.activateComponent(http, "http");
> +
> + DefaultServiceMixClient client = new DefaultServiceMixClient(jbi);
> + Destination d =
> client.createDestination("service:urn:test:provider");
> + InOut me = d.createInOutExchange();
> + me.getInMessage().setContent(new
> StringSource("<hello>world</hello>"));
> +
> + boolean ok = client.sendSync(me);
> + Exception exception = me.getError();
> + assertTrue(exception == null);
> + client.done(me);
> + }
> +}
> Index: src/test/java/org/apache/servicemix/http/HttpTxTest.java
> ===================================================================
> --- src/test/java/org/apache/servicemix/http/HttpTxTest.java (revision
> 921248)
> +++ src/test/java/org/apache/servicemix/http/HttpTxTest.java (working copy)
> @@ -36,6 +36,7 @@
> import org.apache.servicemix.tck.ExchangeCompletedListener;
> import org.jencks.GeronimoPlatformTransactionManager;
>
> +
> public class HttpTxTest extends TestCase {
>
> private ExchangeCompletedListener listener;
> Property changes on: src/main/java/org/apache/servicemix/http
> ___________________________________________________________________
> Added: svn:ignore
> + .HttpConfiguration.java.swp
> Index: src/main/java/org/apache/servicemix/http/HttpComponent.java
> ===================================================================
> --- src/main/java/org/apache/servicemix/http/HttpComponent.java
> (revision 921248)
> +++ src/main/java/org/apache/servicemix/http/HttpComponent.java
> (working copy)
> @@ -178,6 +178,7 @@
> btp.setMaxThreads(getConfiguration().getJettyClientThreadPoolSize());
> tempClient.setThreadPool(btp);
>
> tempClient.setConnectorType(org.mortbay.jetty.client.HttpClient.CONNECTOR_SELECT_CHANNEL);
> +
> tempClient.setTimeout(getConfiguration().getProviderExpirationTime());
> tempClient.start();
> return tempClient;
> }
> Index: src/main/java/org/apache/servicemix/http/HttpConfiguration.java
> ===================================================================
> --- src/main/java/org/apache/servicemix/http/HttpConfiguration.java
> (revision 921248)
> +++ src/main/java/org/apache/servicemix/http/HttpConfiguration.java
> (working copy)
> @@ -113,6 +113,11 @@
> * servicemix is 60000msec)
> */
> private int consumerProcessorSuspendTime = 60000;
> +
> + /***
> + * HttpProvider endpoint expiration time.
> + */
> + private int providerExpirationTime = 60000;
>
> /**
> * Number of times a given HTTP request will be tried until successful.
> If
> @@ -525,7 +530,29 @@
> save();
> }
>
> +
> + /***
> + * Gets the number of milliseconds that the provider will wait for a
> response before expiring.
> + * @return an int representing the ammout of time the provider will wait
> for a response before expiring.
> + */
> + public int getProviderExpirationTime() {
> + return providerExpirationTime;
> + }
> +
> /**
> + * Sets the number of milliseconds the provider will wait for a response
> (read timeout).
> + * The default default value for Jetty is 300000.
> + *
> + * @param providerExpirationTime an int representing the number of
> milliseconds the Jetty will wait for a response.
> + * @org.apache.xbean.Property description="the number of miliseconds
> Jetty will susspend the processing of a request. The default is 60000."
> + */
> + public void setProviderExpirationTime(int providerExpirationTime) {
> + this.providerExpirationTime = providerExpirationTime;
> + }
> +
> +
> +
> + /**
> * Gets the number of times a request will be tried before an error is
> * created.
> *
> @@ -621,6 +648,7 @@
> setProperty(componentName + ".connectorMaxIdleTime",
> Integer.toString(connectorMaxIdleTime));
> setProperty(componentName + ".consumerProcessorSuspendTime", Integer
> .toString(consumerProcessorSuspendTime));
> + setProperty(componentName + ".providerExpirationTime",
> Integer.toString(providerExpirationTime));
> setProperty(componentName + ".retryCount",
> Integer.toString(retryCount));
> setProperty(componentName + ".proxyHost", proxyHost);
> setProperty(componentName + ".proxyPort",
> Integer.toString(proxyPort));
> @@ -719,6 +747,10 @@
> consumerProcessorSuspendTime = Integer.parseInt(properties
> .getProperty(componentName +
> ".consumerProcessorSuspendTime"));
> }
> + if (properties.getProperty(componentName +
> ".providerExpirationTime") != null) {
> + providerExpirationTime = Integer.parseInt(properties
> + .getProperty(componentName + ".providerExpirationTime"));
> + }
> if (properties.getProperty(componentName + ".retryCount") != null) {
> retryCount =
> Integer.parseInt(properties.getProperty(componentName + ".retryCount"));
> }
> Index: src/main/java/org/apache/servicemix/http/HttpConfigurationMBean.java
> ===================================================================
> --- src/main/java/org/apache/servicemix/http/HttpConfigurationMBean.java
> (revision 921248)
> +++ src/main/java/org/apache/servicemix/http/HttpConfigurationMBean.java
> (working copy)
> @@ -65,7 +65,11 @@
> int getConsumerProcessorSuspendTime();
>
> void setConsumerProcessorSuspendTime(int consumerProcessorSuspendTime);
> +
> + int getProviderExpirationTime();
>
> + void setProviderExpirationTime(int providerExpirationTime);
> +
> int getRetryCount();
>
> void setRetryCount(int retryCount);
> Index:
> src/main/java/org/apache/servicemix/http/endpoints/HttpProviderEndpoint.java
> ===================================================================
> ---
> src/main/java/org/apache/servicemix/http/endpoints/HttpProviderEndpoint.java
> (revision 921248)
> +++
> src/main/java/org/apache/servicemix/http/endpoints/HttpProviderEndpoint.java
> (working copy)
> @@ -63,6 +63,7 @@
> private HttpProviderMarshaler marshaler;
> private String locationURI;
> private int clientSoTimeout = 60000;
> + private int providerExpirationTime = 300000;
> private HttpClient jettyClient;
> private boolean ownClient = false;
>
> @@ -294,6 +295,7 @@
> }
> }
> jettyClient.setSoTimeout(getClientSoTimeout());
> + jettyClient.setTimeout(getProviderExpirationTime());
> jettyClient.start();
> } else {
> ownClient = false;
> @@ -323,6 +325,20 @@
> this.clientSoTimeout = clientTimeout;
> }
>
> + public int getProviderExpirationTime() {
> + return providerExpirationTime;
> + }
> +
> + /***
> + * Sets the number of milliseconds the endpoint will wait to read the
> response. The default value is 300000.
> + *
> + * @param providerExpirationTime an int specifying the number of
> milliseconds to wait for a response before expiring.
> + * @org.apache.xbean.Property description="the number of milliseconds to
> wait for a response before expiring."
> + */
> + public void setProviderExpirationTime(int providerExpirationTime) {
> + this.providerExpirationTime = providerExpirationTime;
> + }
> +
> public void validate() throws DeploymentException {
> super.validate();
> if (marshaler == null) {
> Index: src/main/resources/META-INF/spring/servicemix-http.xml
> ===================================================================
> --- src/main/resources/META-INF/spring/servicemix-http.xml (revision
> 921248)
> +++ src/main/resources/META-INF/spring/servicemix-http.xml (working copy)
> @@ -45,6 +45,7 @@
> <bean id="servicemix-http-configuration"
> class="org.apache.servicemix.http.HttpConfiguration">
> <property name="connectorMaxIdleTime"
> value="${connectorMaxIdleTime}" />
> <property name="consumerProcessorSuspendTime"
> value="${consumerProcessorSuspendTime}" />
> + <property name="providerExpirationTime"
> value="${providerExpirationTime}" />
> <property name="jettyClientThreadPoolSize"
> value="${jettyClientThreadPoolSize}" />
> <property name="jettyConnectorClassName"
> value="${jettyConnectorClassName}" />
> <property name="jettyThreadPoolSize" value="${jettyThreadPoolSize}"
> />
> @@ -92,6 +93,7 @@
> <osgix:cm-properties id="cmProps"
> persistent-id="org.apache.servicemix.components.http">
> <prop key="connectorMaxIdleTime">30000</prop>
> <prop key="consumerProcessorSuspendTime">60000</prop>
> + <prop key="providerExpirationTime">300000</prop>
> <prop key="jettyClientThreadPoolSize">16</prop>
> <prop
> key="jettyConnectorClassName">org.mortbay.jetty.nio.SelectChannelConnector</prop>
> <prop key="jettyThreadPoolSize">255</prop>
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.