首页 > 其他 > 详细

dubbo 试用全过程

时间:2016-08-16 23:51:37      阅读:328      评论:0      收藏:0      [点我收藏+]

1.下载地址

https://github.com/alibaba/dubbo/

2.导入IDE

cd ~/dubbo
mvn eclipse:eclipse(执行了两次mvn下载,第一次执行失败有些jar没下载下来,重新执行成功)

Eclipse -> Menu -> File -> Import -> Exsiting Projects to Workspace -> Browse -> Finish

3. 如果修改dubbo源码则需要重新构建dubbo
cd ~/dubbo
mvn clean install -Dmaven.test.skip
cd dubbo/target

4.Install the zookeeper registry:
cd ~
wget http://www.apache.org/dist//zookeeper/zookeeper-3.3.3/zookeeper-3.3.3.tar.gz
tar zxvf zookeeper-3.3.3.tar.gz
cd zookeeper-3.3.3/conf
cp zoo_sample.cfg zoo.cfg
vi zoo.cfg
- edit: dataDir=/home/xxx/data
cd ../bin
./zkServer.sh start
cd ~/dubbo/dubbo-demo-provider/conf
vi dubbo.properties
- edit: dubbo.registry.adddress=zookeeper://127.0.0.1:2181
cd ../bin
./restart.sh
cd ~/dubbo/dubbo-demo-consumer/conf
vi dubbo.properties
- edit: dubbo.registry.adddress=zookeeper://127.0.0.1:2181
cd ../bin
./restart.sh
cd ~/dubbo/dubbo-simple-monitor/conf
vi dubbo.properties
- edit: dubbo.registry.adddress=zookeeper://127.0.0.1:2181
cd ../bin
./restart.sh

5.启动过程
00zkServer.cmd
01start_provider.bat
02start_consumer.bat(可选,基本不用)
03start_monitor.bat (可选,监控使用,会占用本地8080端口)
04start_admin.bat(基本不用,管理控制器部署在tomcat下即可,dubbo-admin-2.5.4-SNAPSHOT.war)

6.服务端开发
通过dubbo自带例子下进行开发,采用maven构建,mvn build

7.客户端开发
通过java工程开发,但是至少需要导入如下jar
技术分享

8.管理控制台
http://127.0.0.1:8087(8080端口被监控应用占用了,找了好长时间的原因)
dubbo-admin-2.5.4-SNAPSHOT.war(该war一定要部署在tomcat/webapp/ROOT下面)

root/rooot
消费者访问服务必须长连接才能在管理控制台看见消费者,因为是基于zookeeper进行连接的,一但客户端线程结束,则立马会断开zookeeper的连接
9.客户端事例代码
技术分享
 1 package com.rigid;
 2 
 3 import java.io.IOException;
 4 
 5 import org.springframework.context.support.FileSystemXmlApplicationContext;
 6 
 7 import com.alibaba.dubbo.demo.VendorService;
 8 
 9 public class Main3 {
10 
11     /**
12      * @param args
13      * @throws IOException 
14      */
15     public static void main(String[] args) throws IOException {
16         FileSystemXmlApplicationContext context = new FileSystemXmlApplicationContext(
17                 "/bin/conf/spring.*");
18         
19         context.start();
20 
21         VendorService vendorService = (VendorService) context.getBean("vendorService");
22 
23         vendorService.createVendor("rigid");
24         
25         System.in.read();  
26 
27     }
28 
29 }
View Code
技术分享
1 <?xml version="1.0" encoding="UTF-8"?>
2 
3 <beans xmlns="http://www.springframework.org/schema/beans"
4     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
5     xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
6     
7     <bean id="orderService" class="com.rigid.OrderService"></bean>    
8     
9 </beans>
View Code

 


dubbo 试用全过程

原文:http://www.cnblogs.com/rigid/p/5778140.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!