You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by khuss <ka...@alcatel-lucent.com> on 2012/07/18 22:32:43 UTC

setting http soTimeout via setHeader() is not working

Hi All,
I am trying to set a timeout for an HTTP connection. Based on the
documentation, we need to pass a query parameter "soTimeout=<timeout value>"
to activate the timeout.

I am able to get this working with the following route definition

from("direct:start")
  .to("http://test-timeout-url?httpClient.soTimeout=5000")

However, I need to dynamically create the URL so I am trying the following:

from("direct:start")
  .setHeader(Exchange.HTTP_URI,
simple("http://test-timeout-url?httpClient.soTimeout=5000"))


The above code doesn't enforce the timeout for some reason. Is there any
other way to implement the timeout when we need to dynamically build a URL?

Thanks for your help.


--
View this message in context: http://camel.465427.n5.nabble.com/setting-http-soTimeout-via-setHeader-is-not-working-tp5716218.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: setting http soTimeout via setHeader() is not working

Posted by Claus Ibsen <cl...@gmail.com>.
On Thu, Jul 19, 2012 at 5:25 PM, khuss <ka...@alcatel-lucent.com> wrote:
> Just to clarify more: We need to build the URI based on a parameter that is
> passed in the request. This means we need to access the Exchange object to
> get the request parameter and append that to the URI.
>
> I do not see how we can do this without using the setHeader() method.
> Unfortunately, the timeout mechanism doesn't work when we use setHeader().
>

Yes the recipient list can do that, just use an expression / method
call / simple etc. to build the URI with the soTimeout value you want.


>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/setting-http-soTimeout-via-setHeader-is-not-working-tp5716218p5716257.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen

Re: setting http soTimeout via setHeader() is not working

Posted by khuss <ka...@alcatel-lucent.com>.
Just to clarify more: We need to build the URI based on a parameter that is
passed in the request. This means we need to access the Exchange object to
get the request parameter and append that to the URI. 

I do not see how we can do this without using the setHeader() method.
Unfortunately, the timeout mechanism doesn't work when we use setHeader().



--
View this message in context: http://camel.465427.n5.nabble.com/setting-http-soTimeout-via-setHeader-is-not-working-tp5716218p5716257.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: setting http soTimeout via setHeader() is not working

Posted by khuss <ka...@alcatel-lucent.com>.
Thanks for the pointer. However, this doesn't help. The way the code is
structured, we have another class called RequestProcessor to frame the
request and dynamically change the URI using setHeader(). 

--
View this message in context: http://camel.465427.n5.nabble.com/setting-http-soTimeout-via-setHeader-is-not-working-tp5716218p5716250.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: setting http soTimeout via setHeader() is not working

Posted by Claus Ibsen <cl...@gmail.com>.
On Wed, Jul 18, 2012 at 10:32 PM, khuss
<ka...@alcatel-lucent.com> wrote:
> Hi All,
> I am trying to set a timeout for an HTTP connection. Based on the
> documentation, we need to pass a query parameter "soTimeout=<timeout value>"
> to activate the timeout.
>
> I am able to get this working with the following route definition
>
> from("direct:start")
>   .to("http://test-timeout-url?httpClient.soTimeout=5000")
>
> However, I need to dynamically create the URL so I am trying the following:
>
> from("direct:start")
>   .setHeader(Exchange.HTTP_URI,
> simple("http://test-timeout-url?httpClient.soTimeout=5000"))
>
>
> The above code doesn't enforce the timeout for some reason. Is there any
> other way to implement the timeout when we need to dynamically build a URL?
>

See this FAQ
http://camel.apache.org/how-do-i-use-dynamic-uri-in-to.html


> Thanks for your help.
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/setting-http-soTimeout-via-setHeader-is-not-working-tp5716218.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen