dubbo demo实现
粗略的写了一个dubbo的demo,使用了alibaba的dubbo,还有zookeeper来做配置中心
参考资料地址: http://dubbo.io/User+Guide-zh.htm#UserGuide-zh-%E5%85%A5%E9%97%A8
需要依赖的jar包
首先如果使用Spring的话,需要引入Spring的jar包: spring中使用了commons-logging<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
</dependency>然后是引入alibab的dubbo的jar包,这个包需要JDK1.5+
而且用到了log4j:
建议使用dubbo-2.3.3以上版本的zookeeper注册中心客户端
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>dubbo</artifactId>
<version>2.3.4</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>log4j-over-slf4j</artifactId>
</dependency>
zookeeper的依赖包:支持zkclient和curator两种Zookeeper客户端实现:从2.2.0版本开始缺省为zkclient实现,以提升zookeeper客户端的健状性。从2.3.0版本开始支持可选curator实现。
<dependency> <groupId>org.apache.zookeeper</groupId> <artifactId>zookeeper</artifactId> <version>3.3.3</version></dependency><dependency> <groupId>com.github.sgroschupf</groupId> <artifactId>zkclient</artifactId> <version>0.1</version></dependency>
provider的dubbo配置部分:<?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.xsd
http://code.alibabatech.com/schema/dubbo
http://code.alibabatech.com/schema/dubbo/dubbo.xsd">
<!- 提供方应用信息,用于计算依赖关系 ->
<dubbo:application name="hello-world-app"/>
<!- 使用zookeeper注册中心暴露服务地址 ->
<dubbo:registry address="zookeeper://zk.dev.corp.qunar.com:2181"/>
<!- 用dubbo协议在20880端口暴露服务 ->
<dubbo:protocol name="dubbo" port="20880"/>
<!- 声明需要暴露的服务接口 ->
<dubbo:service interface="com.qunar.zhao.provider.api.IHelloWorld" ref="helloWorldService"/>
<!- 和本地bean一样实现服务 ->
<bean id="helloWorldService" class="com.qunar.zhao.dubbbo.HelloWorldServiceImp.HelloWorldService"/>
</beans>
consumer的dubbo的配置部分:
<?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.xsd
http://code.alibabatech.com/schema/dubbo
http://code.alibabatech.com/schema/dubbo/dubbo.xsd">
<!- 消费方应用名,用于计算依赖关系,不是匹配条件,不要与提供方一样 ->
<dubbo:application name="consumer-of-helloworld-app" />
<!- 使用multicast广播注册中心暴露发现服务地址 ->
<dubbo:registry address="zookeeper://zk.dev.corp.qunar.com:2181" />
<!- 生成远程服务代理,可以和本地bean一样使用demoService ->
<dubbo:reference id="helloWorldService" interface="com.qunar.zhao.provider.api.IHelloWorld" />
</beans>
jar包的安装:http://www.cnblogs.com/zhaoxinshanwei/p/5948561.html
dubbo demo实现的更多相关文章
- JEECG&Dubbo Demo
jeecg框架service与dao层类图 吴水成Dubbo Demo项目架构图
- zookeeper+dubbo+demo
zookeeper下载地址 https://archive.apache.org/dist/zookeeper/ zookeeper安装和使用 windows环境 https://blog.csdn. ...
- 配置Dubbo Demo遇到的坑之一---找不到dubbo.xsd文件
原文地址:https://blog.csdn.net/qq_36654870/article/details/80603302 1.dubbo.xsd文件不能读取 因为阿里http://code.al ...
- Dubbo系列(3)_官方Demo说明
一.本文目的 通过Dubbo的官方Demo介绍,学会搭建一个简单的Dubbo程序,包括服务端.客户端.接口等. Demo地址:https://github.com/alibaba/dubbo/ ...
- Dubbo入门—搭建一个最简单的Demo框架
一.Dubbo背景和简介 1.电商系统的演进 Dubbo开始于电商系统,因此在这里先从电商系统的演变讲起. a.单一应用框架(ORM) 当网站流量很小时,只需一个应用,将所有功能如下单支付等都部署在一 ...
- Dubbo入门---搭建一个最简单的Demo框架(转)
Dubbo背景和简介 Dubbo开始于电商系统,因此在这里先从电商系统的演变讲起. 单一应用框架(ORM) 当网站流量很小时,只需一个应用,将所有功能如下单支付等都部署在一起,以减少部署节点和成本. ...
- dubbo系列一:dubbo介绍、dubbo架构、dubbo的官网入门使用demo
一.dubbo介绍 Dubbo是阿里巴巴公司开源的一个高性能优秀的服务框架,使得应用可通过高性能的RPC实现服务的输出和输入功能,可以和Spring框架无缝集成.简单地说,dubbo是一个基于Spri ...
- dubbo环境搭建与tomcat集成、DEMO示例、常见问题(最完整版本、带管理控制台、监控中心、zookeeper)
以windows为例,linux基本相同,开发环境一般linux,个人环境一般windows(如果不开额外vm的话). 示例以dubbo官方自带demo为例子,进行整合和稍加修改测试. 0.dubbo ...
- Dubbo简介---搭建一个最简单的Demo框架
Dubbo背景和简介 Dubbo开始于电商系统,因此在这里先从电商系统的演变讲起. 单一应用框架(ORM) 当网站流量很小时,只需一个应用,将所有功能如下单支付等都部署在一起,以减少部署节点和成本. ...
随机推荐
- EXT学习之——EXT下拉框默认绑定第一个值
//默认第一个下拉框绑定值if (this.moduleCombo.store.getAt(0) != undefined) { this.moduleCombo.setValue(this.modu ...
- mongodb根据字符长度作为条件查询
{ $where:"this.XXX.length==2" } 用$where条件查询,等号要用==.虽说$where查询可能效率不是很好,这只是我能想到的,有更好的方法欢迎指教
- mysql 主从复制原理
主从形式 mysql主从复制 灵活 一主一从 主主复制 一主多从---扩展系统读取的性能,因为读是在从库读取的: 多主一从---5.7开始支持 联级复制--- 用途及条件 mysql主 ...
- 消息框用法MessageBox
关键字:C# MessageBox 消息对话框 在程序中,我们经常使用消息对话框给用户一定的信息提示,如在操作过程中遇到错误或程序异常,经常会使用这种方式给用于以提示.在C#中,MessageBox消 ...
- mysql问题小结
1.数据表存在,但查询时提示不存在 原因:默认情况下,mysql在windows对表名大小不敏感(lower_case_table_names=1),在linux上大小敏感(lower_case_ta ...
- Asp.net Page指令
Page指令为编译器编译页面时使用的指令 指令的格式为 <%@ [Directive] [Attribute=value]%> <%@ Page Language="C#& ...
- MVC dirname(——FILE——)
1.MVC全名是Model View Controller,是模型(model)-视图(view)-控制器(controller)的缩写,一种软件设计典范,用一种业务逻辑.数据.界面显示分离的方法组织 ...
- WebForm 简单控件、复合控件
简单控件: Label:被编译成span 样式表里设置lable的高度: display:inline-block; Text --文本 ForeColor --字体颜色 Visible -- ...
- 解决方法:An error occurred on the server when processing the URL. Please contact the system administrator
在WINDOWS7或SERVER2008上安装了IIS7.5,调试ASP程序时出现以下错误: An error occurred on the server when processing the U ...
- C++(MFC)中WebBrowser去除3D边框的方法(实现IDocHostUIHandler接口)控制 WebBrowser 控件的外观和行为
在 CSDN 上经常看到以下两个问题:1.在 MFC 应用程序中,如果创建了一个 WebBrowser 控件(包括 CHtmlView 在内),如何可以把该控件的三维边框禁止掉?2.在 MFC 应用程 ...