`
zhaohaolin
  • 浏览: 985349 次
  • 性别: Icon_minigender_1
  • 来自: 杭州
社区版块
存档分类
最新评论

spring http invoker 高级篇

阅读更多

默认情况下,客户端的HttpInvokerProxy使用J2SE的HTTP Client来建立连接,即 org.springframework.remoting.httpinvoker.SimpleHttpInvokerRequestExecutor, 可以通过设置httpInvokerRequestExecutor属性来改变默认配置,spring提供了另外一种 HttpClient,org.springframework.remoting.httpinvoker.CommonsHttpInvokerRequestExecutor。

修改配置如下:

<bean id="httpService"
  class="org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean">
  <property name="serviceUrl">
   <value>http://vm.netqin.com:4080/ucs/service/httpService</value>
  </property>
  <property name="serviceInterface" value="com.netqin.baike.service.UcService">
  </property>
  <property name="httpInvokerRequestExecutor">
   <bean
    class="org.springframework.remoting.httpinvoker.CommonsHttpInvokerRequestExecutor" />
  </property>
 </bean>

需要在项目中引入两个jar包:

commons-codec-x.x.jar

commons-httpclient-x.x.x.jar

CommonsHttpInvokerRequestExecutor具有HTTP connection pooling,不过通过使用jmeter进行压力测试发现,SimpleHttpInvokerRequestExecutor性能高于 CommonsHttpInvokerRequestExecutor

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics