【问题标题】:how to set max connections for camel Http component如何为骆驼Http组件设置最大连接数
【发布时间】:2016-09-27 07:35:00
【问题描述】:

我使用 servlet 和 camel rest dsl 来定义路由。 我没有在我的应用程序中使用 xml 文件。 如何使用 http 组件选项设置 http 组件的最大连接数?

【问题讨论】:

  • 您需要先尝试一下,如果遇到问题,您可以发布一个问题,清楚地说明您尝试过的内容以及遇到的错误。但同样重要的是,在发布问题之前进行一些基础研究。

标签: rest apache-camel


【解决方案1】:

您可以在此页面上阅读有关它的信息: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>

希望它会有所帮助。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-08-30
    • 2023-04-06
    • 1970-01-01
    • 1970-01-01
    • 2015-08-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多