You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by "Abhishek.Jha09" <ab...@gmail.com> on 2017/03/19 05:44:09 UTC
Overriding HTTP client config while declaring routes.
Hi,
I have a web application from which I'm calling around 50-60 rest/soap apis.
For this, I've created routes in JAVA DSL. Now, to have default application
level timeout settings, I've done configuration like this-
public class DefaultHttpClientConfig implements HttpClientConfigurer { //
http4
@Override
public void configureHttpClient(HttpClientBuilder clientBuilder) {
clientBuilder.setDefaultRequestConfig(
RequestConfig.custom()
.setConnectTimeout(1000)
.setSocketTimeout(1000).build());
}
}
and I've set this in camel context like this-
static CamelContext ctx = new DefaultCamelContext();
static {
try {
HttpComponent httpComponent = ctx.getComponent("http4",
HttpComponent.class);
httpComponent.setConnectionTimeToLive(10);
httpComponent.setHttpClientConfigurer(new DefaultHttpClientConfig());
ctx.addRoutes(new DirectRestRouteBuilder());
ctx.start();
} catch (Exception e) {
e.printStackTrace();
}
}
Now when creating individual routes, I want to override these configuration,
so I'm trying this as shown below-
from("direct:success")
.to("http4://localhost:8089/mockcarrier/success?httpClient.socketTimeout=8000");
However, it seems that the direct configuration is not picked up. Where am I
going wrong?
--
View this message in context: http://camel.465427.n5.nabble.com/Overriding-HTTP-client-config-while-declaring-routes-tp5795765.html
Sent from the Camel - Users mailing list archive at Nabble.com.