小强源码分析系列-Dubbo-源码分析1---调试环境搭建

小强源码分析系列-Dubbo-源码分析1---调试环境搭建

  • 1.下载Dubbo源码
    • 2.编译源码
      • 3.编译完成:
      • 4.代码总览:
      • 5.调试入口:

1.下载Dubbo源码

fork源码到自己github仓库: [Dubbo](https://github.com/apache/incubator-dubbo)
fork源码到仓库可以随意修改代码注解,方便阅读整理。
git clone https://github.com/xxxxxxxx/incubator-dubbo.git
也可以指定下载那个分支版本
git clone --branch dubbo-2.6.6 https://github.com/xxxxxxxx/incubator-dubbo.git

2.编译源码

注:maven版本要求v3.5以上,版本比较低的可以升级下maven版本。

项目根目录输入 :mvn install -Dmaven.test.skip=true

经过漫长的等待终于编译成功,国外maven仓库的下载速度实在是太慢啦,改成阿里云maven仓库速度便飞了起来。

3.编译完成:

小强源码分析系列-Dubbo-源码分析1---调试环境搭建_第1张图片
生成idea项目需要命令 mvn idea:idea
生成eclipse命令需要 mvn eclipse:eclipse
启动IDE工具导入源码。

4.代码总览:

小强源码分析系列-Dubbo-源码分析1---调试环境搭建_第2张图片
如要还没有成功,多试几次就可以了。

5.调试入口:

  1. 我们来打开 dubbo-demo 项目的 dubbo-demo-provider下的Provider 类,直接右键 Debug 运行main方法运行生产者。
  2. 我们来打开 dubbo-demo 项目的 dubbo-demo-consumer下的Consumer 类,直接右键 Debug 运行main方法运行消费者。
    编译完成
[07/03/19 10:11:33:033 CST] main  INFO support.ClassPathXmlApplicationContext: Refreshing org.springframework.context.support.ClassPathXmlApplicationContext@161cd475: startup date [Thu Mar 07 10:11:33 CST 2019]; root of context hierarchy
[07/03/19 10:11:33:033 CST] main  INFO xml.XmlBeanDefinitionReader: Loading XML bean definitions from class path resource [META-INF/spring/dubbo-demo-provider.xml]
[07/03/19 10:11:33:033 CST] main  INFO logger.LoggerFactory: using logger: com.alibaba.dubbo.common.logger.log4j.Log4jLoggerAdapter
[07/03/19 10:11:34:034 CST] main  WARN extension.SpringExtensionFactory:  [DUBBO] No spring extension (bean) named:defaultCompiler, try to find an extension (bean) of type java.lang.String, dubbo version: , current host: 172.16.15.235
[07/03/19 10:11:34:034 CST] main  WARN extension.SpringExtensionFactory:  [DUBBO] No spring extension (bean) named:defaultCompiler, type:java.lang.String found, stop get bean., dubbo version: , current host: 172.16.15.235
[07/03/19 10:11:34:034 CST] main  INFO config.AbstractConfig:  [DUBBO] The service ready on spring started. service: com.alibaba.dubbo.demo.DemoService, dubbo version: , current host: 172.16.15.235
[07/03/19 10:11:34:034 CST] main  INFO config.AbstractConfig:  [DUBBO] Export dubbo service com.alibaba.dubbo.demo.DemoService to local registry, dubbo version: , current host: 172.16.15.235
[07/03/19 10:11:34:034 CST] main  INFO config.AbstractConfig:  [DUBBO] Export dubbo service com.alibaba.dubbo.demo.DemoService to url dubbo://172.16.15.235:20880/com.alibaba.dubbo.demo.DemoService?anyhost=true&application=demo-provider&bean.name=com.alibaba.dubbo.demo.DemoService&bind.ip=172.16.15.235&bind.port=20880&dubbo=2.0.2&generic=false&interface=com.alibaba.dubbo.demo.DemoService&methods=sayHello&pid=12500&qos.port=22222&side=provider×tamp=1551924694626, dubbo version: , current host: 172.16.15.235
[07/03/19 10:11:34:034 CST] main  INFO config.AbstractConfig:  [DUBBO] Register dubbo service com.alibaba.dubbo.demo.DemoService url dubbo://172.16.15.235:20880/com.alibaba.dubbo.demo.DemoService?anyhost=true&application=demo-provider&bean.name=com.alibaba.dubbo.demo.DemoService&bind.ip=172.16.15.235&bind.port=20880&dubbo=2.0.2&generic=false&interface=com.alibaba.dubbo.demo.DemoService&methods=sayHello&pid=12500&qos.port=22222&side=provider×tamp=1551924694626 to registry registry://224.5.6.7:1234/com.alibaba.dubbo.registry.RegistryService?application=demo-provider&dubbo=2.0.2&pid=12500&qos.port=22222®istry=multicast×tamp=1551924694602, dubbo version: , current host: 172.16.15.235
[07/03/19 10:11:35:035 CST] main  INFO transport.AbstractServer:  [DUBBO] Start NettyServer bind /0.0.0.0:20880, export /172.16.15.235:20880, dubbo version: , current host: 172.16.15.235
[07/03/19 10:11:35:035 CST] main  INFO multicast.MulticastRegistry:  [DUBBO] Register: dubbo://172.16.15.235:20880/com.alibaba.dubbo.demo.DemoService?anyhost=true&application=demo-provider&bean.name=com.alibaba.dubbo.demo.DemoService&dubbo=2.0.2&generic=false&interface=com.alibaba.dubbo.demo.DemoService&methods=sayHello&pid=12500&side=provider×tamp=1551924694626, dubbo version: , current host: 172.16.15.235
[07/03/19 10:11:35:035 CST] main  INFO multicast.MulticastRegistry:  [DUBBO] Send broadcast message: register dubbo://172.16.15.235:20880/com.alibaba.dubbo.demo.DemoService?anyhost=true&application=demo-provider&bean.name=com.alibaba.dubbo.demo.DemoService&dubbo=2.0.2&generic=false&interface=com.alibaba.dubbo.demo.DemoService&methods=sayHello&pid=12500&side=provider×tamp=1551924694626 to /224.5.6.7:1234, dubbo version: , current host: 172.16.15.235
[07/03/19 10:11:35:035 CST] DubboMulticastRegistryReceiver  INFO multicast.MulticastRegistry:  [DUBBO] Receive multicast message: register dubbo://172.16.15.235:20880/com.alibaba.dubbo.demo.DemoService?anyhost=true&application=demo-provider&bean.name=com.alibaba.dubbo.demo.DemoService&dubbo=2.0.2&generic=false&interface=com.alibaba.dubbo.demo.DemoService&methods=sayHello&pid=12500&side=provider×tamp=1551924694626 from /172.16.15.235:1234, dubbo version: , current host: 172.16.15.235
[07/03/19 10:11:35:035 CST] main  INFO multicast.MulticastRegistry:  [DUBBO] Subscribe: provider://172.16.15.235:20880/com.alibaba.dubbo.demo.DemoService?anyhost=true&application=demo-provider&bean.name=com.alibaba.dubbo.demo.DemoService&category=configurators&check=false&dubbo=2.0.2&generic=false&interface=com.alibaba.dubbo.demo.DemoService&methods=sayHello&pid=12500&side=provider×tamp=1551924694626, dubbo version: , current host: 172.16.15.235
[07/03/19 10:11:35:035 CST] main  INFO multicast.MulticastRegistry:  [DUBBO] Send broadcast message: subscribe provider://172.16.15.235:20880/com.alibaba.dubbo.demo.DemoService?anyhost=true&application=demo-provider&bean.name=com.alibaba.dubbo.demo.DemoService&category=configurators&check=false&dubbo=2.0.2&generic=false&interface=com.alibaba.dubbo.demo.DemoService&methods=sayHello&pid=12500&side=provider×tamp=1551924694626 to /224.5.6.7:1234, dubbo version: , current host: 172.16.15.235
[07/03/19 10:11:35:035 CST] DubboMulticastRegistryReceiver  INFO multicast.MulticastRegistry:  [DUBBO] Receive multicast message: subscribe provider://172.16.15.235:20880/com.alibaba.dubbo.demo.DemoService?anyhost=true&application=demo-provider&bean.name=com.alibaba.dubbo.demo.DemoService&category=configurators&check=false&dubbo=2.0.2&generic=false&interface=com.alibaba.dubbo.demo.DemoService&methods=sayHello&pid=12500&side=provider×tamp=1551924694626 from /172.16.15.235:1234, dubbo version: , current host: 172.16.15.235
[07/03/19 10:11:36:036 CST] main  WARN multicast.MulticastRegistry:  [DUBBO] Ignore empty notify urls for subscribe url provider://172.16.15.235:20880/com.alibaba.dubbo.demo.DemoService?anyhost=true&application=demo-provider&bean.name=com.alibaba.dubbo.demo.DemoService&category=configurators&check=false&dubbo=2.0.2&generic=false&interface=com.alibaba.dubbo.demo.DemoService&methods=sayHello&pid=12500&side=provider×tamp=1551924694626, dubbo version: , current host: 172.16.15.235

3.注册中心

Demo项目中默认情况下注册中心使用的是Multicast Registry,生产环境使用的是Zookeeper Registry作为注册中心.
如果使用组播协议做为注册发现,不需要启动任何节点,只需要地址相同,就可以相互发现,可以跳过下面内容,用来调试代码一般不需要修改注册中心配置。

如果使用Zookeeper作为注册中心:
1.需要搭建Zookeeper ,启动Zookeeper服务.

2.修改 dubbo-demo-provider.xml ,启动 Provider



3.修改 dubbo-demo-consumer.xml ,启动 Consumer



启动成功后就可以调试了。

2019新的开始,新的里程碑。此系列将会持续更新,敬请关注。

你可能感兴趣的:(Dubbo源码分析)