博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
dubbo+zookeeper
阅读量:7086 次
发布时间:2019-06-28

本文共 8793 字,大约阅读时间需要 29 分钟。

首先是整个项目结构图:

dubbo-service:

1 package com.zto.service;2 3 public interface SayHelloService {4     public String hello(String name);5 }
SayHelloService.java
1 package com.zto.service.impl; 2  3 import com.zto.service.SayHelloService; 4  5 public class SayHelloServiceImpl implements SayHelloService { 6  7     public String hello(String name) { 8         return "hello : " + name; 9     }10 11 }
SayHelloServiceImpl.java
1 package com.zto.app; 2  3 import java.io.IOException; 4  5 import org.springframework.context.support.ClassPathXmlApplicationContext; 6  7 public class Main { 8  9     public static void main(String[] args) throws IOException {10         ClassPathXmlApplicationContext context=new ClassPathXmlApplicationContext(new String[] {"applicationContext-rpc.xml"});11         context.start();12         System.out.println("按任意键退出");13         System.in.read();14     }15 }
Main.java
1 
2
9 10
11 12
13 14
15 16
17 18
19
20 21
applicationContext-rpc.xml
1 
3
4.0.0
4
com.alibaba.zy
5
dubbo-service
6
jar
7
0.0.1-SNAPSHOT
8
dubbo-service Maven Webapp
9
10
11
junit
12
junit
13
3.8.1
14
test
15
16
17
commons-logging
18
commons-logging
19
1.1.1
20
21
22
com.alibaba
23
dubbo
24
2.5.3
25
26
27
org.javassist
28
javassist
29
3.18.1-GA
30
31
32
log4j
33
log4j
34
1.2.15
35
36
37
com.sun.jdmk
38
jmxtools
39
40
41
com.sun.jmx
42
jmxri
43
44
45
jms
46
javax.jms
47
48
49
mail
50
javax.mail
51
52
53
54
55
org.springframework
56
spring
57
2.5.6.SEC03
58
59
60
org.slf4j
61
slf4j-api
62
1.7.6
63
64
65
org.slf4j
66
slf4j-log4j12
67
1.6.1
68
69
70
org.apache.zookeeper
71
zookeeper
72
3.4.6
73
74
75
com.github.sgroschupf
76
zkclient
77
0.1
78
79
80
pom.xml

dubbo-consumer:

1 package com.zto.consumer; 2  3 import org.springframework.context.support.ClassPathXmlApplicationContext; 4  5 import com.zto.service.SayHelloService; 6  7 public class ConsumerThd { 8  9     public void sayHello() {10         ClassPathXmlApplicationContext context=new ClassPathXmlApplicationContext(new String[]{"applicationContext-rpc*.xml"});11         context.start();12         SayHelloService sayHelloService = (SayHelloService) context.getBean("sayHelloService");13         System.out.println(sayHelloService.hello("world"));14     }15 }
ConsumerThd.java
1 package com.zto.test; 2  3 import com.zto.consumer.ConsumerThd; 4  5 public class Main { 6  7     public static void main(String[] args) { 8         ConsumerThd thd=new ConsumerThd(); 9         thd.sayHello();10     }11 12 }
Main.java
1 
2
9 10
消费者
11 12
13 14
15
16 17
18 19
20
21
applicationContext-rpc.xml
1 
3
4.0.0
4
com.zto
5
dubbo-consumer
6
0.0.1-SNAPSHOT
7
dubbo-consumer
8
9
10
junit
11
junit
12
3.8.1
13
test
14
15
16
commons-logging
17
commons-logging
18
1.1.1
19
20
21
com.alibaba
22
dubbo
23
2.5.3
24
25
26
org.javassist
27
javassist
28
3.18.1-GA
29
30
31
log4j
32
log4j
33
1.2.15
34
35
36
com.sun.jdmk
37
jmxtools
38
39
40
com.sun.jmx
41
jmxri
42
43
44
jms
45
javax.jms
46
47
48
mail
49
javax.mail
50
51
52
53
54
org.springframework
55
spring
56
2.5.6.SEC03
57
58
59
org.slf4j
60
slf4j-api
61
1.7.6
62
63
64
org.slf4j
65
slf4j-log4j12
66
1.6.1
67
68
69
org.apache.zookeeper
70
zookeeper
71
3.4.6
72
73
74
com.alibaba.zy
75
dubbo-service
76
0.0.1-SNAPSHOT
77
78
79
pom.xml

启动顺序:先启动-service 提供者  在启动消费者-consumer

Zookeeper配置

tickTime=2000

initLimit=10
syncLimit=5
dataDir=E:\zookeeper-3.4.6\data     选填自己存放路径
clientPort=2181
server.1=localhost:2287:3387

 项目地址链接: http://pan.baidu.com/s/1jIMyZsy 密码: 3h47  

 

转载于:https://www.cnblogs.com/zyjava/p/5646338.html

你可能感兴趣的文章
cmder git bash 使用
查看>>
关于SVG的viewBox
查看>>
Fastboot的使用简单教程
查看>>
Python 黑帽编程 4.2 Sniffer之数据本地存储和加载
查看>>
第 33 章 Message Queuing & RPC
查看>>
Awesome Reinforcement Learning
查看>>
使用Iterator遍历Sheet(POI)验证及解释结果有序性
查看>>
HttpContext.Current.Cache 过期时间
查看>>
提问的智慧
查看>>
AIX平台上11.2 Grid Infrastructure RDBMS进程的user是grid用户?
查看>>
MySQL 存储过程常用SQL语句收集
查看>>
理解dockerfile是如何工作的?
查看>>
VC中分割文件路径的分割类
查看>>
2017年最佳开源网络监控工具
查看>>
彩虹表的概念
查看>>
苹果紧急发布新系统iOS 11.0.1 修复多种BUG
查看>>
输得太不光彩!Uber司机把算法当游戏
查看>>
亚信安全成为 “上海网络与信息安全监测预警平台” 首批发起单位
查看>>
构建基于容器的本机监控系统 应该注意什么?
查看>>
从CSE Asia 2016亚洲消费电子展看智能设备安全
查看>>