我正在尝试为 Camel CXF-RS 组件设置“connectionTimeout”here 它在第 3 方服务上生成 RESTful 请求。默认30000
毫秒太长了。
Exchange exchange = template.send("cxfrs://" + url, new Processor() {
public void process(Exchange exchange) throws Exception {
exchange.setPattern(ExchangePattern.InOut);
Message inMessage = exchange.getIn();
setupDestinationURL(inMessage);
// using the http central client API
inMessage.setHeader(CxfConstants.CAMEL_CXF_RS_USING_HTTP_API, Boolean.TRUE);
// set the Http method
inMessage.setHeader(Exchange.HTTP_METHOD, "PUT");
// set the relative path
inMessage.setHeader(Exchange.HTTP_PATH, url);
// Specify the response class , cxfrs will use InputStream as the response object type
inMessage.setHeader(CxfConstants.CAMEL_CXF_RS_RESPONSE_CLASS, Customer.class);
// set a customer header
inMessage.setHeader("key", "value");
// since we use the Get method, so we don't need to set the message body
inMessage.setBody(null);
}
});
我尝试过将其添加到我们的application-context
正如许多人所建议的那样,但在通过调试时看不到它修改默认值HTTPConduit
and HTTPClientPolicy
课程:
<http-conf:conduit name="*.http-conduit">
<http-conf:client ConnectionTimeout="5000"/>
</http-conf:conduit>
我尝试附加
"?httpClientAPI=true&connectionTimeout=5000"
作为 url 字符串的选项。
任何帮助或指导将不胜感激。
添加http-conf:conduit
元素在application-context
正如你所做的那样,这是要走的路,应该有效。是什么让你说它不是?
后端服务器通常需要很长时间才能回答,after连接已建立;在这种情况下设置ReceiveTimeout
与ConnectionTimeout
.
这是一个示例camel Route,它消耗RS请求并调用第三方RS服务器; ReceiveTimeout 和 ConnectionTimeout 参数按预期工作。
<cxf:rsServer id="rsFrontServer" address="..." serviceClass="..."/>
<cxf:rsClient id="rsBackendClient" address=".../" serviceClass="..."/>
<http-conf:conduit name="*.http-conduit">
<http-conf:client ReceiveTimeout="5000" ConnectionTimeout="5000"/>
</http-conf:conduit>
<camelContext xmlns="http://camel.apache.org/schema/spring">
<route id="front">
<from uri="cxfrs:bean:rsFrontServer"/>
<!-- do stuff -->
<to uri="cxfrs:bean:rsBackendClient"/>
</route>
</camelContext>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)