spring-nginxsync.xml 1.18 KB
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
       http://www.springframework.org/schema/beans/spring-beans-3.1.xsd">


    <bean id="restClientPool" class="org.apache.http.impl.conn.PoolingHttpClientConnectionManager"
          p:maxTotal="10"
          p:defaultMaxPerRoute="5">
    </bean>

    <bean id="restClientBuilder" class="org.apache.http.impl.client.HttpClientBuilder" factory-method="create"
          p:connectionManager-ref="restClientPool">
    </bean>

    <bean id="restClient" factory-bean="restClientBuilder" factory-method="build">
    </bean>

    <bean id="clientFactory" class="org.springframework.http.client.HttpComponentsClientHttpRequestFactory"
          p:connectTimeout="10000" p:readTimeout="40000">
        <constructor-arg ref="restClient"></constructor-arg>
    </bean>

    <bean id="restTemplate" class="org.springframework.web.client.RestTemplate">
        <constructor-arg ref="clientFactory"></constructor-arg>
    </bean>
</beans>