Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
武汉红喜
whatsmars
提交
aa06dc9b
W
whatsmars
项目概览
武汉红喜
/
whatsmars
通知
3
Star
0
Fork
1
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
W
whatsmars
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
aa06dc9b
编写于
1月 06, 2018
作者:
武汉红喜
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
多协议及hessian协议测试
上级
a2ede8b7
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
64 addition
and
7 deletion
+64
-7
pom.xml
pom.xml
+16
-0
whatsmars-dubbo/README.md
whatsmars-dubbo/README.md
+2
-0
whatsmars-dubbo/whatsmars-dubbo-consumer/pom.xml
whatsmars-dubbo/whatsmars-dubbo-consumer/pom.xml
+10
-0
whatsmars-dubbo/whatsmars-dubbo-consumer/src/main/java/org/hongxi/whatsmars/dubbo/demo/consumer/DemoConsumer.java
...rg/hongxi/whatsmars/dubbo/demo/consumer/DemoConsumer.java
+9
-2
whatsmars-dubbo/whatsmars-dubbo-consumer/src/main/resources/META-INF/spring/dubbo-demo-consumer.xml
...rc/main/resources/META-INF/spring/dubbo-demo-consumer.xml
+5
-0
whatsmars-dubbo/whatsmars-dubbo-consumer/src/main/resources/dubbo.properties
...tsmars-dubbo-consumer/src/main/resources/dubbo.properties
+3
-1
whatsmars-dubbo/whatsmars-dubbo-provider/pom.xml
whatsmars-dubbo/whatsmars-dubbo-provider/pom.xml
+11
-0
whatsmars-dubbo/whatsmars-dubbo-provider/src/main/resources/META-INF/spring/dubbo-demo-provider.xml
...rc/main/resources/META-INF/spring/dubbo-demo-provider.xml
+5
-3
whatsmars-dubbo/whatsmars-dubbo-provider/src/main/resources/dubbo.properties
...tsmars-dubbo-provider/src/main/resources/dubbo.properties
+3
-1
未找到文件。
pom.xml
浏览文件 @
aa06dc9b
...
...
@@ -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>
...
...
whatsmars-dubbo/README.md
浏览文件 @
aa06dc9b
...
...
@@ -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"
/>
...
...
whatsmars-dubbo/whatsmars-dubbo-consumer/pom.xml
浏览文件 @
aa06dc9b
...
...
@@ -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>
...
...
whatsmars-dubbo/whatsmars-dubbo-consumer/src/main/java/org/hongxi/whatsmars/dubbo/demo/consumer/DemoConsumer.java
浏览文件 @
aa06dc9b
...
...
@@ -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
whatsmars-dubbo/whatsmars-dubbo-consumer/src/main/resources/META-INF/spring/dubbo-demo-consumer.xml
浏览文件 @
aa06dc9b
...
...
@@ -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
whatsmars-dubbo/whatsmars-dubbo-consumer/src/main/resources/dubbo.properties
浏览文件 @
aa06dc9b
...
...
@@ -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
whatsmars-dubbo/whatsmars-dubbo-provider/pom.xml
浏览文件 @
aa06dc9b
...
...
@@ -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>
...
...
whatsmars-dubbo/whatsmars-dubbo-provider/src/main/resources/META-INF/spring/dubbo-demo-provider.xml
浏览文件 @
aa06dc9b
...
...
@@ -14,12 +14,14 @@
<!--<dubbo:application name="whatsmars_provider" />-->
<!--<!– 使用zookeeper注册中心暴露服务地址 –>-->
<!--<dubbo:registry address="zookeeper://127.0.0.1:2181" />-->
<!--<!– 用dubbo协议在20880端口暴露服务 –>-->
<!--<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
whatsmars-dubbo/whatsmars-dubbo-provider/src/main/resources/dubbo.properties
浏览文件 @
aa06dc9b
...
...
@@ -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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录