- 浏览: 21934 次
最新评论
做了一个 Hessian, CXF, Spring httpinvoke 速度对比
时间消耗 cxf > spring httpinvoke > hessian
顺序调用1W次所耗时间
并发为10, 调用1W次所耗时间
当然, 都知道 cxf 和 hessian 实现以及应用场景不太一样, 但差这么多还是很意外的..
另外在并发测试时, spring httpinvoke cpu 消耗明显更高.
=============================================================
测试代码:
服务端
客户端
时间消耗 cxf > spring httpinvoke > hessian
顺序调用1W次所耗时间
hessian | 2652-2922 |
spring httpinvoke | 4080-4949 |
cxf | 9732-10432 |
并发为10, 调用1W次所耗时间
hessian | 1625-1753 |
spring httpinvoke | 3165-3338 |
cxf | 5709-5863 |
当然, 都知道 cxf 和 hessian 实现以及应用场景不太一样, 但差这么多还是很意外的..
另外在并发测试时, spring httpinvoke cpu 消耗明显更高.
=============================================================
测试代码:
服务端
public class Param implements Serializable { private static final long serialVersionUID = 7414597783500374225L; private Integer i; private String s; private Long l; private List<Param> list = new ArrayList<Param>(); private boolean b; ...... } public class Result implements Serializable { private static final long serialVersionUID = 2729153186117404170L; private Integer i; private String s; private Long l; private List<Result> list; private boolean b; ...... }
@WebService public interface TestService { Result method(Param p); }
@Service @WebService(endpointInterface = "org.alex.test.webservice.TestService") public class TestServiceImpl implements TestService { @Override public Result method(Param p) { Result r = new Result(); BeanUtils.copyProperties(p, r); return r; } }
<!-- cxf --> <import resource="classpath:META-INF/cxf/cxf.xml" /> <import resource="classpath:META-INF/cxf/cxf-extension-soap.xml" /> <import resource="classpath:META-INF/cxf/cxf-servlet.xml" /> <jaxws:endpoint id="testCxfService" implementor="org.alex.test.webservice.TestServiceImpl" address="/cxf" /> <bean id="testServiceImpl" class="org.alex.test.webservice.TestServiceImpl" /> <!-- hessian --> <bean name="/hes" class="org.springframework.remoting.caucho.HessianServiceExporter"> <property name="service" ref="testServiceImpl" /> <property name="serviceInterface" value="org.alex.test.webservice.TestService" /> </bean> <!-- spring http invoke --> <bean name="/spr" class="org.springframework.remoting.httpinvoker.HttpInvokerServiceExporter"> <property name="service" ref="testServiceImpl" /> <property name="serviceInterface" value="org.alex.test.webservice.TestService" /> </bean>
客户端
public class Client { static String CXF = "cxfService"; static String HESSIAN = "hesService"; static String SPRING = "sprService"; public static void main(String[] args) { ApplicationContext ac = new ClassPathXmlApplicationContext("client.xml"); TestService service = (TestService) ac.getBean(SPRING); Param p = new Param(); p.setI(100); p.setB(true); p.setL(1000L); p.setS("123456789123456789abcdefghijklmnopqrstuvwxyz!@#$%^&*()_\r\n\\\t"); p.getList().add(new Param()); p.getList().add(new Param()); p.getList().add(new Param()); service.method(p); long now = System.currentTimeMillis(); for (int i = 0; i < 10000; i++) { service.method(p); } System.out.println(System.currentTimeMillis() - now); } }
public class MultiThreadClient { static String CXF = "cxfService"; static String HESSIAN = "hesService"; static String SPRING = "sprService"; public static void main(String[] args) { ApplicationContext ac = new ClassPathXmlApplicationContext("client.xml"); TestService service = (TestService) ac.getBean(HESSIAN); Param p = new Param(); p.setI(100); p.setB(true); p.setL(1000L); p.setS("123456789123456789abcdefghijklmnopqrstuvwxyz!@#$%^&*()_\r\n\\\t"); p.getList().add(new Param()); p.getList().add(new Param()); p.getList().add(new Param()); service.method(p); ExecutorService exe = Executors.newFixedThreadPool(10); Task task = new Task(service, p); long now = System.currentTimeMillis(); for (int i = 0; i < 10000; i++) { exe.submit(task); } exe.shutdown(); while (!exe.isTerminated()) { } System.out.println(System.currentTimeMillis() - now); } private static class Task implements Runnable { TestService service; Param p; public Task(TestService service, Param p) { this.service = service; this.p = p; } @Override public void run() { service.method(p); } } }
<jaxws:client id="cxfService" serviceClass="org.alex.test.webservice.TestService" address="http://localhost:8080/webservice/cxf/cxf?wsdl" /> <bean id="hesService" class="org.springframework.remoting.caucho.HessianProxyFactoryBean"> <property name="serviceUrl" value="http://localhost:8080/webservice/app/hes" /> <property name="serviceInterface" value="org.alex.test.webservice.TestService" /> </bean> <bean id="sprService" class="org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean"> <property name="serviceUrl" value="http://localhost:8080/webservice/app/spr" /> <property name="serviceInterface" value="org.alex.test.webservice.TestService" /> </bean>
发表评论
-
httpclient 4.3 ignore certificate
2014-04-22 10:01 585public static CloseableHtt ... -
ActiveMQ 2 ActiveMQ ReplicationLevelDB
2014-01-08 21:26 1207这里只是简述我的配置以及碰到的问题. <broker ... -
ActiveMQ 1
2014-01-06 17:30 720下载安装 ActiveMQ 网上有 N 多例子, 就不说什么了 ... -
spring 集成 cxf 时, @PostConstruct 执行2次.
2013-12-02 18:26 917引用https://issues.apache.org/jir ... -
Java Object 有多大? (转帖)
2013-11-14 16:44 832public class ObjectMemorySize ... -
Executors.newCachedThreadPool 线程重用
2013-11-14 16:09 1105想起一个小细节: 线程池 CachedThreadPool ... -
一个最简单的 RPC 程序
2013-11-14 12:47 966一个最简单的 RPC 程序. Service 接口 pu ... -
spring mvc 3.2.4 使用@ResponseBody 返回 406
2013-10-02 22:57 1162<mvc:annotation-driven co ... -
spring 3.1.1 使用 @Value 注解无法注入属性.
2013-09-25 17:24 1870spring 3.1.1 使用 @Value 注解无法注入属性 ... -
Java OSGi 入门
2013-08-26 20:02 936OSGi 的核心就是一个 JVM ... -
比较 fastjson gson.
2013-08-09 20:56 2757一个简单的 Model . public class Mo ... -
javassist case
2013-07-29 19:39 891一个普通的类,一个 name 属性, 只有 getter 方法 ... -
dev tips
2013-05-28 11:21 608换行符: String lineSeparator = (St ... -
Spring 自定义命名空间 xsd
2013-05-21 19:08 1548编写这两个文件 META-INF/spring.handler ...
相关推荐
这是Hessian和Spring集成的示例,具体步骤请参考本人博客: http://blog.csdn.net/jjasun/article/details/29593083
hessian与spring整合的jar包
NULL 博文链接:https://ml5858258-sina-com.iteye.com/blog/1260842
Hessian与Spring整合需要jar包,需要的同学进行下载学习
Hessian与spring整合的dome
该案例主要为hessian+spring结合进行接口开发,参数可直接传输!
1.名称:Spring + Hessian + Spring MVC(包括Server和Client).zip 2.来源:自己实现 3.备注:项目有两个系统,包括Server端和Client端,项目已经跑通,可以实现。 4.注意:client中pom.xml里最后的一个jar包,需要...
引入该工程,在接口上添加@hessianService注解,在client定义url,在client端的xml里面配置hessianClientBuilder,在server里面配置hessianServerBuilder,并实例化接口。在client端里面使用接口并注入即可。
Hessian是一个轻量级的remoting on http工具,使用简单的方法提供了RMI(Remote Method Invocation,远程方法调用)的功能。采用的是二进制RPC(Remote Procedure Call Protocol,远程过程调用协议)协议,因为采用...
NULL 博文链接:https://zwustudy.iteye.com/blog/1611651
引入该工程,在接口上添加@hessianService注解,在client定义url,在client端的xml里面配置hessianClientBuilder,在server里面配置hessianServerBuilder,并实例化接口。在client端里面使用接口并注入即可。
Spring集成Hessian案例
SpringMVC整合Hessian的简单案例,使用Maven管理,idea工具开发,案例中配置了两个接口的服务发布
NULL 博文链接:https://wo-niu.iteye.com/blog/2200720
NULL 博文链接:https://tangzhifei.iteye.com/blog/921127
Hessian是一个轻量级的remoting onhttp工具,使用简单的方法提供了RMI的功能。 相比WebService,Hessian更简单、快捷。采用的是二进制RPC协议,因为采用的是二进制协议,所以它很适合于发送二进制数据。参考文档地址...
hessian+srping 整合示例文档
使用eclipse maven工程搭建hessian远程服务demo 分服务端的整合和客户端 建议阅读相关博客http://blog.csdn.net/heisemuyangquan/article/details/79460528
纯Hessian的入门例子教程,还有Hessian和Spring整合的例子教程。 代码上传之前都运行通过的
spring aop hessian 基础demo 部署即可运行