如何设置 Camel HTTP4 连接超时选项? [英] How to set Camel HTTP4 connection timeout options?

查看:40
本文介绍了如何设置 Camel HTTP4 连接超时选项?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Camel HTTP4 的文档相当明确您可以为 HTTP4 组件设置以下选项:connectionRequestTimeoutconnectTimeoutsocketTimeout.

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

然而,这些在文档中被列为通用组件选项,而不是查询选项(如果设置为查询选项,则会被忽略——它们只是在调用时传递到 HTTP 端点).所以我不确定如何设置它们.HTTPComponent 类似乎没有这些选项的任何 setter 方法.

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.

文档确实有一个部分 使用客户端超时 - SO_TIMEOUT,链接到单元测试源,在其中将 httpClient.soTimeout 设置为查询选项.但是,当我尝试这样做时,出现错误:

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:

无法解析端点:https4://myhost/myapi/v1?bridgeEndpoint=true&httpClient.soTimeout=1000 由于: 有 1 个参数无法在端点上设置.检查 uri 参数是否拼写正确并且它们是端点的属性.未知参数=[{soTimeout=1000}

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}

推荐答案

事实证明文档不太正确.所有这些超时参数都可以通过查询参数选项设置,但它们需要以 httpClient. 为前缀.以下是对我有用的方法:

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

我通过使用小得离谱的值 (1 ms) 进行了测试,结果显示读取超时"错误.

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

看起来 httpClient 的可用选项是 RequestConfig.Builder.

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

这篇关于如何设置 Camel HTTP4 连接超时选项?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆