提交 aa06dc9b 编写于 作者: 武汉红喜's avatar 武汉红喜

多协议及hessian协议测试

上级 a2ede8b7
......@@ -57,6 +57,8 @@
<httpcomponents.version>4.5.3</httpcomponents.version>
<gson.version>2.8.2</gson.version>
<guava.version>20.0</guava.version>
<jetty.version>6.1.26</jetty.version>
<hessian.version>4.0.7</hessian.version>
<junit.version>4.12</junit.version>
<!-- for maven compiler&resources plugin -->
......@@ -104,6 +106,20 @@
<scope>provided</scope>
</dependency>
<!-- jetty -->
<dependency>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty</artifactId>
<version>${jetty.version}</version>
</dependency>
<!-- hessian -->
<dependency>
<groupId>com.caucho</groupId>
<artifactId>hessian</artifactId>
<version>${hessian.version}</version>
</dependency>
<!-- mybatis -->
<dependency>
<groupId>org.mybatis</groupId>
......
......@@ -17,6 +17,8 @@
- 集群容错模式:默认 cluster="failover",其他 failfast,failsafe,failback,forking,broadcast
- 负载均衡:默认 loadbalance="random",其他 roundrobin,leastactive,consistenthash
- 线程模型:<dubbo:protocol name="dubbo" dispatcher="all" threadpool="fixed" threads="100" />
如果事件处理的逻辑能迅速完成,并且不会发起新的 IO 请求,比如只是在内存中记个标识,则直接在 IO 线程上处理更快,因为减少了线程池调度。
但如果事件处理逻辑较慢,或者需要发起新的 IO 请求,比如需要查询数据库,则必须派发到线程池,否则 IO 线程阻塞,将导致不能接收其它请求。
- 直连提供者:<dubbo:reference id="xxxService" interface="com.alibaba.xxx.XxxService" url="dubbo://localhost:20890" />
- 只订阅(禁用注册):<dubbo:registry address="10.20.153.10:9090" register="false" />
- 人工管理服务上下线:<dubbo:registry address="10.20.141.150:9090" dynamic="false" />
......
......@@ -43,6 +43,16 @@
<artifactId>zkclient</artifactId>
<version>0.9</version>
</dependency>
<!-- for hessian protocol -->
<dependency>
<groupId>com.caucho</groupId>
<artifactId>hessian</artifactId>
</dependency>
<dependency>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty</artifactId>
</dependency>
</dependencies>
<build>
......
......@@ -14,10 +14,17 @@ public class DemoConsumer {
context.start();
DemoService demoService = (DemoService) context.getBean("demoService"); // 获取远程服务代理
String hello = demoService.sayHello("world"); // 执行远程方法
String hello = demoService.sayHello("dubbo"); // 执行远程方法
System.out.println(hello); // 显示调用结果
DemoService demoService2 = (DemoService) context.getBean("demoService2"); // 获取远程服务代理
String hello2 = demoService2.sayHello("hessian直连"); // 执行远程方法
System.out.println(hello2); // 显示调用结果
DemoService demoService3 = (DemoService) context.getBean("demoService3"); // 获取远程服务代理
String hello3 = demoService3.sayHello("hessian"); // 执行远程方法
System.out.println(hello3); // 显示调用结果
}
}
\ No newline at end of file
......@@ -14,4 +14,9 @@
<dubbo:reference id="demoService" interface="org.hongxi.whatsmars.dubbo.demo.api.DemoService" retries="2" />
<dubbo:reference id="demoService2" interface="org.hongxi.whatsmars.dubbo.demo.api.DemoService"
url="hessian://127.0.0.1:8080/org.hongxi.whatsmars.dubbo.demo.api.DemoService" />
<dubbo:reference id="demoService3" interface="org.hongxi.whatsmars.dubbo.demo.api.DemoService" protocol="hessian" />
</beans>
\ No newline at end of file
......@@ -23,4 +23,6 @@ dubbo.registry.address=zookeeper://127.0.0.1:2181
#dubbo.registry.address=dubbo://127.0.0.1:9090
#dubbo.monitor.protocol=registry
#dubbo.log4j.file=logs/dubbo-demo-consumer.log
#dubbo.log4j.level=WARN
\ No newline at end of file
#dubbo.log4j.level=WARN
dubbo.qos.port=33333
\ No newline at end of file
......@@ -43,6 +43,17 @@
<artifactId>zkclient</artifactId>
<version>0.9</version>
</dependency>
<!-- for hessian protocol -->
<dependency>
<groupId>com.caucho</groupId>
<artifactId>hessian</artifactId>
</dependency>
<dependency>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty</artifactId>
</dependency>
<dependency>
<groupId>org.hongxi</groupId>
<artifactId>whatsmars-dubbo-service</artifactId>
......
......@@ -14,12 +14,14 @@
<!--<dubbo:application name="whatsmars_provider" />-->
<!--&lt;!&ndash; 使用zookeeper注册中心暴露服务地址 &ndash;&gt;-->
<!--<dubbo:registry address="zookeeper://127.0.0.1:2181" />-->
<!--&lt;!&ndash; 用dubbo协议在20880端口暴露服务 &ndash;&gt;-->
<!--<dubbo:protocol name="dubbo" port="20880" />-->
<!-- 多协议配置 -->
<dubbo:protocol name="dubbo" port="20880" />
<dubbo:protocol name="hessian" port="8080" server="jetty" />
<context:component-scan base-package="org.hongxi.whatsmars.dubbo"/>
<dubbo:service interface="org.hongxi.whatsmars.dubbo.demo.api.DemoService" ref="demoService"
timeout="1000" />
timeout="1000" /> <!-- 默认配了 protocol="dubbo,hessian" -->
</beans>
\ No newline at end of file
......@@ -26,4 +26,6 @@ dubbo.protocol.name=dubbo
dubbo.protocol.port=20882
dubbo.service.loadbalance=roundrobin
#dubbo.log4j.file=logs/dubbo-demo-consumer.log
#dubbo.log4j.level=WARN
\ No newline at end of file
#dubbo.log4j.level=WARN
dubbo.qos.port=22222
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册