【发布时间】:2016-09-27 07:35:00
【问题描述】:
我使用 servlet 和 camel rest dsl 来定义路由。 我没有在我的应用程序中使用 xml 文件。 如何使用 http 组件选项设置 http 组件的最大连接数?
【问题讨论】:
-
您需要先尝试一下,如果遇到问题,您可以发布一个问题,清楚地说明您尝试过的内容以及遇到的错误。但同样重要的是,在发布问题之前进行一些基础研究。
标签: rest apache-camel
我使用 servlet 和 camel rest dsl 来定义路由。 我没有在我的应用程序中使用 xml 文件。 如何使用 http 组件选项设置 http 组件的最大连接数?
【问题讨论】:
标签: rest apache-camel
您可以在此页面上阅读有关它的信息:http://camel.apache.org/http.html。 在下面的示例中,我们将最大连接数设置为 5 而不是默认的 2。
<bean id="http" class="org.apache.camel.component.http.HttpComponent">
<property name="camelContext" ref="camel"/>
<property name="httpConnectionManager" ref="myHttpConnectionManager"/>
</bean>
<bean id="myHttpConnectionManager" class="org.apache.commons.httpclient.MultiThreadedHttpConnectionManager">
<property name="params" ref="myHttpConnectionManagerParams"/>
</bean>
<bean id="myHttpConnectionManagerParams" class="org.apache.commons.httpclient.params.HttpConnectionManagerParams">
<property name="defaultMaxConnectionsPerHost" value="5"/>
</bean>
然后我们可以像往常一样在路由中使用它:
<camelContext id="camel" xmlns="http://camel.apache.org/schema/spring" trace="true">
<route>
<from uri="direct:start"/>
<to uri="http://www.google.com"/>
<to uri="mock:result"/>
</route>
</camelContext>
希望它会有所帮助。
【讨论】: