Spring4 HttpInvoker 超時配置

1.spring4x 後 httpinvoker 默認採用 SimpleHttpInvokerRequestExecutor 調度器,默認不設超時時間。

2.網上大多數採用CommonsHttpInvokerRequestExecutor。

        兩個缺點,1)性能低於SimpleHttpInvokerRequestExecutor;2)spring4x後移除該類。

3.採用 spring4x 的方法實現 HttpInvoker 超時配置

       1)寫一個類,繼承SimpleHttpInvokerRequestExecutor。然後代碼中設定超時時間 和其他自定義功能;

       2)配置SimpleHttpInvokerRequestExecutor的超時時間。(推薦)

<bean id="tspServiceHttpInvokerServices" class="org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean">
    <property name="serviceUrl" value="http://localhost:8080/api/remoting/SimHttpInvoker"></property>
    <property name="serviceInterface" value="sim.api.remoting.ServiceRemoting"></property>

    <property name="httpInvokerRequestExecutor">
        <ref bean="httpInvokerRequestExecutor"/>
    </property>
</bean>

<bean id="httpInvokerRequestExecutor" class="org.springframework.remoting.httpinvoker.SimpleHttpInvokerRequestExecutor">
    <property name="connectTimeout" value="5000"></property>
    <property name="readTimeout" value="10000"></property>
</bean>

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章