How to set Camel HTTP4 connection timeout options?

蹲街弑〆低调 提交于 2021-01-29 08:50:14

问题


The documentation at Camel HTTP4 is quite clear that you can set the following options for the HTTP4 component: connectionRequestTimeout, connectTimeout, and socketTimeout.

However, these are listed as general component options, not query options in the documentation (and are ignored if set as query options -- they just get passed onto the HTTP endpoint when called). So I'm not sure how to set them. The HTTPComponent class does not seem to have any setter methods for these options.

The documentation does have a section Using client timeout - SO_TIMEOUT, that links to unit test source where they set httpClient.soTimeout as a query option. However, when I try that I get an error:

Failed to resolve endpoint: https4://myhost/myapi/v1?bridgeEndpoint=true&httpClient.soTimeout=1000 due to: There are 1 parameters that couldn't be set on the endpoint. Check the uri if the parameters are spelt correctly and that they are properties of the endpoint. Unknown parameters=[{soTimeout=1000}


回答1:


It turns out that the documentation isn't quite right. All of those timeout parameters can be set via query param options, but they need to be prefixed with httpClient. . Here is what worked for me:

?httpClient.connectTimeout=10000&httpClient.connectionRequestTimeout=10000&httpClient.socketTimeout=30000

I verified by testing with ridiculously small values (1 ms) and it produced "read timed out" errors.

It looks the availble options for httpClient are the setter values on RequestConfig.Builder.



来源:https://stackoverflow.com/questions/65723470/how-to-set-camel-http4-connection-timeout-options

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!