Saturday, 29 July 2017

Camel HTTP endpoint Timeout configuration using Apache HttpClient

I have used  Apache HttpClient for a timeout in Camel HTTP end point.It specifically for HTTP calls.

We have various types of timeouts
  1. The Connection Timeout – the time to establish the connection with the remote host
  2. The Socket Timeout – the time to waiting for data – after the connection was established; maximum time wait for response
  3. The Connection Manager Timeout (http.connection-manager.timeout) – the time to wait for a connection from the connection manager/pool
I have used Socket Timeout to handle timeouts in Camel HTTP endpoint.Below things based on Spring DSL.We can do the same way in Java DSL.

Syntax :

{{HTTPURL}}?httpClient.soTimeout=50(Timout in milliseconds)

Syntax with Camel route:

   <route id="BLOG_TIMEOUT">
        <from uri="direct:blog.start"/>
         <to  uri="{{HTTPURL}}?httpClient.soTimeout=50(Timout in milliseconds)" />
        <to uri="direct:blog.end"/>
    </route>

BLOG_TIMEOUT -- route id
direct:blog.start -- from uri
{{HTTPURL}}?httpClient.soTimeout=50(Timout in milliseconds) -- http enpoint with socket timeout 
blog.start - one more endpoint

No comments:

Post a Comment