且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

骆驼cxfrs RESTful客户端/ProducerTemplate ConnectionTimeout

更新时间:2023-11-30 12:50:46

像往常一样在application-context中添加http-conf:conduit元素是可行的方法.是什么让您说不呢?

Adding the http-conf:conduit element in application-context as you did is the way to go and should work. What makes you say it does not?

通常,后端服务器在建立连接后 花费的时间太长.在这种情况下,设置ReceiveTimeoutConnectionTimeout同样重要.

Quite often a backend server take too long to answer, after the connection is made; in this case setting ReceiveTimeout is as important as ConnectionTimeout.

这是一个骆驼路线示例,它使用RS请求并调用第三方RS服务器. ReceiveTimeout和ConnectionTimeout参数按预期工作.

This is a sample camel Route which consumes RS requests and calls a third-party RS server; the ReceiveTimeout and ConnectionTimeout parameters work as expected.

<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>