Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
caopu16
whatsmars
提交
b2ff2a82
W
whatsmars
项目概览
caopu16
/
whatsmars
与 Fork 源项目一致
Fork自
武汉红喜 / whatsmars
通知
1
Star
0
Fork
0
代码
文件
提交
分支
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 搜索 >>
提交
b2ff2a82
编写于
1月 12, 2018
作者:
武汉红喜
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
test
上级
8e1f9ca1
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
63 addition
and
27 deletion
+63
-27
whatsmars-dubbo/whatsmars-dubbo-consumer/src/main/java/org/hongxi/whatsmars/dubbo/demo/consumer/AsyncConsumer.java
...g/hongxi/whatsmars/dubbo/demo/consumer/AsyncConsumer.java
+46
-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
+0
-19
whatsmars-dubbo/whatsmars-dubbo-consumer/src/main/resources/META-INF/spring/dubbo-async-consumer.xml
...c/main/resources/META-INF/spring/dubbo-async-consumer.xml
+17
-0
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
+0
-8
未找到文件。
whatsmars-dubbo/whatsmars-dubbo-consumer/src/main/java/org/hongxi/whatsmars/dubbo/demo/consumer/AsyncConsumer.java
0 → 100644
浏览文件 @
b2ff2a82
/**
* Created by shenhongxi on 2017/6/21.
*/
package
org.hongxi.whatsmars.dubbo.demo.consumer
;
import
com.alibaba.dubbo.rpc.RpcContext
;
import
com.alibaba.dubbo.rpc.service.EchoService
;
import
org.hongxi.whatsmars.dubbo.demo.api.BarService
;
import
org.hongxi.whatsmars.dubbo.demo.api.DemoService
;
import
org.hongxi.whatsmars.dubbo.demo.api.vo.Bar
;
import
org.springframework.context.support.ClassPathXmlApplicationContext
;
import
java.util.concurrent.Future
;
public
class
AsyncConsumer
{
public
static
void
main
(
String
[]
args
)
throws
Exception
{
//Prevent to get IPV6 address,this way only work in debug mode
//But you can pass use -Djava.net.preferIPv4Stack=true,then it work well whether in debug mode or not
System
.
setProperty
(
"java.net.preferIPv4Stack"
,
"true"
);
ClassPathXmlApplicationContext
context
=
new
ClassPathXmlApplicationContext
(
new
String
[]{
"META-INF/spring/dubbo-async-consumer.xml"
});
context
.
start
();
// 异步调用
async
(
context
);
}
private
static
void
async
(
ClassPathXmlApplicationContext
context
)
throws
Exception
{
// 异步调用
DemoService
demoService5
=
(
DemoService
)
context
.
getBean
(
"demoService5"
);
demoService5
.
sayHello
(
"aysc"
);
Future
<
String
>
helloFuture
=
RpcContext
.
getContext
().
getFuture
();
BarService
barService
=
(
BarService
)
context
.
getBean
(
"barService"
);
barService
.
findBar
(
"m123456"
);
Future
<
Bar
>
barFuture
=
RpcContext
.
getContext
().
getFuture
();
String
hello5
=
helloFuture
.
get
();
Bar
bar
=
barFuture
.
get
();
System
.
out
.
println
(
hello5
);
System
.
out
.
println
(
bar
);
}
}
\ No newline at end of file
whatsmars-dubbo/whatsmars-dubbo-consumer/src/main/java/org/hongxi/whatsmars/dubbo/demo/consumer/DemoConsumer.java
浏览文件 @
b2ff2a82
...
@@ -22,9 +22,6 @@ public class DemoConsumer {
...
@@ -22,9 +22,6 @@ public class DemoConsumer {
ClassPathXmlApplicationContext
context
=
new
ClassPathXmlApplicationContext
(
new
String
[]{
"META-INF/spring/dubbo-demo-consumer.xml"
});
ClassPathXmlApplicationContext
context
=
new
ClassPathXmlApplicationContext
(
new
String
[]{
"META-INF/spring/dubbo-demo-consumer.xml"
});
context
.
start
();
context
.
start
();
// 异步调用
// async(context);
// dubbo protocol
// dubbo protocol
DemoService
demoService
=
(
DemoService
)
context
.
getBean
(
"demoService"
);
// 获取远程服务代理
DemoService
demoService
=
(
DemoService
)
context
.
getBean
(
"demoService"
);
// 获取远程服务代理
String
hello
=
demoService
.
sayHello
(
"dubbo"
);
// 执行远程方法
String
hello
=
demoService
.
sayHello
(
"dubbo"
);
// 执行远程方法
...
@@ -54,20 +51,4 @@ public class DemoConsumer {
...
@@ -54,20 +51,4 @@ public class DemoConsumer {
}
}
private
static
void
async
(
ClassPathXmlApplicationContext
context
)
throws
Exception
{
// 异步调用
DemoService
demoService5
=
(
DemoService
)
context
.
getBean
(
"demoService5"
);
demoService5
.
sayHello
(
"aysc"
);
Future
<
String
>
helloFuture
=
RpcContext
.
getContext
().
getFuture
();
BarService
barService
=
(
BarService
)
context
.
getBean
(
"barService"
);
barService
.
findBar
(
"m123456"
);
Future
<
Bar
>
barFuture
=
RpcContext
.
getContext
().
getFuture
();
String
hello5
=
helloFuture
.
get
();
Bar
bar
=
barFuture
.
get
();
System
.
out
.
println
(
hello5
);
System
.
out
.
println
(
bar
);
}
}
}
\ No newline at end of file
whatsmars-dubbo/whatsmars-dubbo-consumer/src/main/resources/META-INF/spring/dubbo-async-consumer.xml
0 → 100644
浏览文件 @
b2ff2a82
<?xml version="1.0" encoding="UTF-8"?>
<beans
xmlns=
"http://www.springframework.org/schema/beans"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xmlns:dubbo=
"http://code.alibabatech.com/schema/dubbo"
xsi:schemaLocation=
"http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
http://code.alibabatech.com/schema/dubbo http://code.alibabatech.com/schema/dubbo/dubbo.xsd"
>
<dubbo:reference
id=
"demoService5"
interface=
"org.hongxi.whatsmars.dubbo.demo.api.DemoService"
>
<dubbo:method
name=
"sayHello"
async=
"true"
/>
</dubbo:reference>
<dubbo:reference
id=
"barService"
interface=
"org.hongxi.whatsmars.dubbo.demo.api.BarService"
>
<dubbo:method
name=
"findBar"
async=
"true"
/>
</dubbo:reference>
</beans>
\ No newline at end of file
whatsmars-dubbo/whatsmars-dubbo-consumer/src/main/resources/META-INF/spring/dubbo-demo-consumer.xml
浏览文件 @
b2ff2a82
...
@@ -22,12 +22,4 @@
...
@@ -22,12 +22,4 @@
<dubbo:reference
id=
"demoService4"
group=
"new"
interface=
"org.hongxi.whatsmars.dubbo.demo.api.DemoService"
/>
<dubbo:reference
id=
"demoService4"
group=
"new"
interface=
"org.hongxi.whatsmars.dubbo.demo.api.DemoService"
/>
<dubbo:reference
id=
"demoService5"
interface=
"org.hongxi.whatsmars.dubbo.demo.api.DemoService"
>
<dubbo:method
name=
"sayHello"
async=
"true"
/>
</dubbo:reference>
<dubbo:reference
id=
"barService"
interface=
"org.hongxi.whatsmars.dubbo.demo.api.BarService"
>
<dubbo:method
name=
"findBar"
async=
"true"
/>
</dubbo:reference>
</beans>
</beans>
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录