So, I have a route which essentially looks like this-
from("direct:send_success")
.to("http4://localhost:8089/mock/success?httpClient.socketTimeout=1000");
Using this way, I'm able to apply socket timeout of 1 sec successfully. I am using ProducerTemplate to invoke this route. This is all fine. But when I change the route to-
from("direct:send_success")
.to("http4://localhost:8089/mock/success");
And route invocation to-
ProducerTemplate pt = ctx.createProducerTemplate();
Exchange ex = pt.send("direct:send_success", exOb -> {
HttpComponent httpComp = exOb.getContext().getComponent("http4", HttpComponent.class);
exOb.getContext().getComponent("http4", HttpComponent.class).setHttpClientConfigurer(httpClientBuilder -> {
HttpClientBuilder
.create()
.setDefaultRequestConfig(requestConfigWithTimeout(1000))
.build();
});
});
And the method requestConfigWithTimeout() as-
private static RequestConfig requestConfigWithTimeout(int timeoutInMilliseconds) {
return RequestConfig.copy(RequestConfig.DEFAULT)
.setSocketTimeout(timeoutInMilliseconds)
.build();
}
The timeout settings are not applied. Where am I going wrong?