You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by kalyan <re...@gmail.com> on 2013/05/28 18:17:50 UTC

Problem with httpClient.connectionManagerTimeout on Camel 2.10.4

Hello,

I have tried "httpClient.connectionManagerTimeout" in the following way.

from("servlet:///test")
   .process(new MyProcessor())
       
.to("http://<ipaddress-not-existing>:8080/context??bridgeEndpoint=true&httpClient.connectionManagerTimeout=1")

>From this I expected it to timeout immediately. However, Camel sends the
request and waits for the response for more than 30 seconds.

Why is the above example not working ?

Also, how do I simulate a "Connection Timeout" using camel (need it for a
testcase).

Thanks in advance.

-Kalyan




--
View this message in context: http://camel.465427.n5.nabble.com/Problem-with-httpClient-connectionManagerTimeout-on-Camel-2-10-4-tp5733367.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Problem with httpClient.connectionManagerTimeout on Camel 2.10.4

Posted by Babak Vahdat <ba...@swissonline.ch>.
Hi

The httpClient.connectionManagerTimeout option doesn't bring the effect
you're expecting, see the Javadoc for it's semantics:

http://hc.apache.org/httpclient-3.x/apidocs/org/apache/commons/httpclient/params/HttpClientParams.html

If an IP-Address can't be resolved you will immediately end up with
java.net.UnknownHostException or the likes on the HttpProducer side.

Regarding simulating a "Connection Timeout", you could write your own
HttpConnectionManager, e.g. do sleep for X seconds before returning a new
HttpConnection:

http://hc.apache.org/httpclient-3.x/apidocs/org/apache/commons/httpclient/HttpConnectionManager.html

For this you may want to to decorate the SimpleHttpConnectionManager
implementation with the Thread.sleep() calls:

http://hc.apache.org/httpclient-3.x/apidocs/org/apache/commons/httpclient/SimpleHttpConnectionManager.html

Babak


kalyan wrote
> Hello,
> 
> I have tried "httpClient.connectionManagerTimeout" in the following way.
> 
> from("servlet:///test")
>    .process(new MyProcessor())
>         .to("http://
> <ipaddress-not-existing>
> :8080/context??bridgeEndpoint=true&httpClient.connectionManagerTimeout=1")
> 
> From this I expected it to timeout immediately. However, Camel sends the
> request and waits for the response for more than 30 seconds.
> 
> Why is the above example not working ?
> 
> Also, how do I simulate a "Connection Timeout" using camel (need it for a
> testcase).
> 
> Thanks in advance.
> 
> -Kalyan





--
View this message in context: http://camel.465427.n5.nabble.com/Problem-with-httpClient-connectionManagerTimeout-on-Camel-2-10-4-tp5733367p5733378.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Problem with httpClient.connectionManagerTimeout on Camel 2.10.4

Posted by Babak Vahdat <ba...@swissonline.ch>.
Yeah right, indeed what Claus has proposed is much easier to implement and
also elegant thanks to the "route-advice" facility in Camel.  Indeed on Page
182 of the Book there's an exact matching example for your use case:

@Test
public void testSimulateErrorUsingInterceptors() throws Exception {
   RouteDefinition route = context.getRouteDefinitions().get(0);

   route.adviceWith(context, new RouteBuilder() {

      public void configure() throws Exception { 
       interceptSendToEndpoint("http://*").skipSendToOriginalEndpoint()
      .process(new SimulateHttpErrorProcessor());

   }

});

Most probably once again I should go through the Chapter 6 and read it more
carefully a second time :-)

Babak


Claus Ibsen-2 wrote
> For testing purpose you can take a look at
> http://camel.apache.org/testing
> 
> And for example use advice with to intercept and skip sending to http
> endpoints, where you can detour and throw your own exceptions to
> simulate the erorr
> http://camel.apache.org/advicewith.html
> 
> If you have a copy of Camel in Action, then check chapter 6, its all
> about testing. And section 6.3 about simulating errors.
> 
> On Tue, May 28, 2013 at 6:17 PM, kalyan &lt;

> register.kalyan@

> &gt; wrote:
>> Hello,
>>
>> I have tried "httpClient.connectionManagerTimeout" in the following way.
>>
>> from("servlet:///test")
>>    .process(new MyProcessor())
>>
>> .to("http://
> <ipaddress-not-existing>
> :8080/context??bridgeEndpoint=true&httpClient.connectionManagerTimeout=1")
>>
>> From this I expected it to timeout immediately. However, Camel sends the
>> request and waits for the response for more than 30 seconds.
>>
>> Why is the above example not working ?
>>
>> Also, how do I simulate a "Connection Timeout" using camel (need it for a
>> testcase).
>>
>> Thanks in advance.
>>
>> -Kalyan
>>
>>
>>
>>
>> --
>> View this message in context:
>> http://camel.465427.n5.nabble.com/Problem-with-httpClient-connectionManagerTimeout-on-Camel-2-10-4-tp5733367.html
>> Sent from the Camel - Users mailing list archive at Nabble.com.
> 
> 
> 
> -- 
> Claus Ibsen
> -----------------
> www.camelone.org: The open source integration conference.
> 
> Red Hat, Inc.
> FuseSource is now part of Red Hat
> Email: 

> cibsen@

> Web: http://fusesource.com
> Twitter: davsclaus
> Blog: http://davsclaus.com
> Author of Camel in Action: http://www.manning.com/ibsen





--
View this message in context: http://camel.465427.n5.nabble.com/Problem-with-httpClient-connectionManagerTimeout-on-Camel-2-10-4-tp5733367p5733389.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Problem with httpClient.connectionManagerTimeout on Camel 2.10.4

Posted by Claus Ibsen <cl...@gmail.com>.
For testing purpose you can take a look at
http://camel.apache.org/testing

And for example use advice with to intercept and skip sending to http
endpoints, where you can detour and throw your own exceptions to
simulate the erorr
http://camel.apache.org/advicewith.html

If you have a copy of Camel in Action, then check chapter 6, its all
about testing. And section 6.3 about simulating errors.

On Tue, May 28, 2013 at 6:17 PM, kalyan <re...@gmail.com> wrote:
> Hello,
>
> I have tried "httpClient.connectionManagerTimeout" in the following way.
>
> from("servlet:///test")
>    .process(new MyProcessor())
>
> .to("http://<ipaddress-not-existing>:8080/context??bridgeEndpoint=true&httpClient.connectionManagerTimeout=1")
>
> From this I expected it to timeout immediately. However, Camel sends the
> request and waits for the response for more than 30 seconds.
>
> Why is the above example not working ?
>
> Also, how do I simulate a "Connection Timeout" using camel (need it for a
> testcase).
>
> Thanks in advance.
>
> -Kalyan
>
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Problem-with-httpClient-connectionManagerTimeout-on-Camel-2-10-4-tp5733367.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
www.camelone.org: The open source integration conference.

Red Hat, Inc.
FuseSource is now part of Red Hat
Email: cibsen@redhat.com
Web: http://fusesource.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen