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>