I’d like to use http4 route, but have it execute inside a thread with a timeout. I already have my http4 route setup, something like this:
from("direct:start")
.setHeader(Exchange.HTTP_QUERY,simple("format=json&count=${in.headers.count}"))
.to("http4://www.host.com/someapi")
.unmarshal().json(JsonLibrary.JACKSON,MyResponseType.class)
.to("bean:SomeBean?method=echo");
I’d like to apply a 100ms timeout around the http call, and route to a failure handler in that case. Does anyone know how that can be done?
You can set a 100ms timeout on the client by specifying
http4://foo?httpClient.soTimeout=100. When a timeout occurs it will probably throw an exception that you can handle like so (off the top of my head, untested code):