使用Spring集成客户端的持久连接/连接重用

使用Spring集成客户端的持久连接/连接重用,spring,rest,spring-integration,Spring,Rest,Spring Integration,我正在使用Spring集成进行REST调用,如下所示 <int:gateway id="ServiceRequestGateway" service-interface="com.company.security.integration.RequestGateway" default-request-channel="RequestChannel" default-reply-channe

我正在使用Spring集成进行REST调用,如下所示

<int:gateway id="ServiceRequestGateway"
                 service-interface="com.company.security.integration.RequestGateway"
                 default-request-channel="RequestChannel"
                 default-reply-channel="ResponseChannel">
        <int:default-header name="Accept" value="application/json; v=5"/>
        <int:default-header name="Content-Type" value="application/json; v=5"/>
        <int:default-header name="ServiceType" expression="#args[1]"/>
    </int:gateway>

    <int-http:outbound-gateway
            id="Outbound_Gateway"
            request-channel="RequestChannel"
            reply-channel="ResponseChannel"
            header-mapper="headerMapper"
            url="${service.host}/{xyzServiceType}"
            http-method="POST"
            expected-response-type="java.lang.String"
            extract-request-payload="true">
        <int-http:uri-variable name="ServiceType" expression="headers['xyzServiceType']" />
    </int-http:outbound-gateway>

然而,在网络上的每次呼叫中都会发生大量ssl握手。如何重用连接并发出多个REST请求?有可能使用keep alive吗

更新-1

添加了对HttpComponents客户端HttpRequestFactory的使用

<int-http:outbound-gateway
        id="NPI_Tokenization_Outbound_Gateway"
        request-channel="NPITokenizationRequestChannel"
        reply-channel="ResponseChannel"
        header-mapper="headerMapper"
        url="${npi.turing.host}/{npiTuringType}"
        http-method="POST"
        expected-response-type="java.lang.String"
        extract-request-payload="true">
    <int-http:uri-variable name="npiTuringType" expression="headers['npiTuringType']" />
</int-http:outbound-gateway>

<bean id="requestFactory"
      class="org.springframework.http.client.HttpComponentsClientHttpRequestFactory">
    <property name="connectTimeout" value="5000"/>
    <property name="readTimeout"    value="5000"/>
</bean>


考虑使用
httpcomponents客户端httprequestfactory
而不是默认的
SimpleClientHttpRequestFactory
。在Apache HTTP客户端中,您可以找到足够多的连接管理选项,包括
保持活动状态

有关更多链接,请参阅。谢谢,我添加了HttpComponents客户端HttpRequestFactory(更新了上面的问题),但是,我没有看到关于如何在Spring集成的上下文中配置keep alive的属性/示例,它已经不是Spring集成的职责了。您必须从
添加
请求工厂
参考。其余的一切取决于
httpcomponents客户端httprequestfactory
配置。对我来说,我们给了你足够的链接来阅读这件事。。。