Duboo入门示例(Idea开发环境)

在学习Dubbo分布式框架时的官方入门例子,很有代表性。简单清晰。
有关Dubbo的概念、概述和简单的配置文件,可以看官方文档的简述
会很快对Duboo有个整体的概念。


准备工作:

首先完成Zookeeper的安装配置


  • 解压后,在conf目录下增加一个zoo.cfg;
  • 用记事本打开简单配置一下:
# The number of milliseconds of each tick  
tickTime=2000  
# The number of ticks that the initial   
# synchronization phase can take  
initLimit=10  
# The number of ticks that can pass between   
# sending a request and getting an acknowledgement  
syncLimit=5  
# the directory where the snapshot is stored.  
dataDir=D:\\zookeeper-3.4.12\\data  
dataDirLog=D:\\zookeeper-3.4.12\\log  
# the port at which the clients will connect  
clientPort=2181  
  • 根据你上述配置的目录(dataDir、dataDirLog),在根目录中新建它们。
  • 点击bin目录下的zkServer.cmd启动


项目配置运行

  • 打开项目
  • 项目是Maven管理的多模块项目,首先引入多模块。

  • 找到我们演示的Demo项目

  • 将consumer和provider模块的xml下的注册中心配置全都换成ZooKeeper

    参数用途简介
  • 先运行Provider.java,再运行Consumer.java(确保打开了Zookeeper注册中心)
  • 运行效果图

    Consumer不断调用Provider提供的实现类,所呈现出的效果。

猜你喜欢

转载自www.cnblogs.com/keeya/p/9253255.html