Dubbo入门demo

概述

初次接触 Dubbo, 先跑个 Hello World, 看看dubbo微服务究竟是如何运作的。下边是快速启动的完整项目。

首先放出工程结构, 方便大家构建demo

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
➜  dubbo-demo tree
.
├── dubbo-api
│   ├── pom.xml
│   └── src
│   ├── main
│   │   ├── java
│   │   │   └── cn
│   │   │   └── idea360
│   │   │   └── api
│   │   │   └── DemoService.java
│   │   └── resources
│   └── test
│   └── java
├── dubbo-consumer
│   ├── pom.xml
│   └── src
│   ├── main
│   │   ├── java
│   │   │   └── cn
│   │   │   └── idea360
│   │   │   └── consumer
│   │   │   └── Consumer.java
│   │   └── resources
│   │   └── dubbo
│   │   └── consumer.xml
│   └── test
│   └── java
├── dubbo-provider
│   ├── pom.xml
│   └── src
│   ├── main
│   │   ├── java
│   │   │   └── cn
│   │   │   └── idea360
│   │   │   └── provider
│   │   │   ├── DemoServiceImpl.java
│   │   │   └── Provider.java
│   │   └── resources
│   │   └── dubbo
│   │   └── provider.xml
│   └── test
│   └── java
└── pom.xml

服务接口

首先创建一个 dubbo-api 服务,用来暴露服务接口

服务接口maven

pom.xml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>dubbo-demo</artifactId>
<groupId>cn.idea360</groupId>
<version>1.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>dubbo-api</artifactId>


<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<encoding>utf-8</encoding>
</configuration>
</plugin>
</plugins>
</build>
</project>

服务接口定义

DemoService.java

1
2
3
4
public interface DemoService {

String sayHello(String name);
}

服务提供者

服务提供方maven

创建 dubbo-provider 服务

pom.xml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>dubbo-demo</artifactId>
<groupId>cn.idea360</groupId>
<version>1.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>dubbo-provider</artifactId>

<!-- 打包方式 -->
<!--<packaging>jar</packaging>-->

<properties>
<!-- 源文件编码格式 -->
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<!-- jdk编译源码版本 -->
<jdk.compile.source.version>1.8</jdk.compile.source.version>
<!-- jdk编译目标版本 -->
<jdk.compile.target.version>1.8</jdk.compile.target.version>
<!-- springframework版本 -->
<springframe.version>5.1.5.RELEASE</springframe.version>
<!-- junit版本 -->
<junit.version>4.12</junit.version>
<!-- log4j版本 -->
<log4j.version>1.2.17</log4j.version>
<!-- dubbo版本 -->
<dubbo.version>2.5.3</dubbo.version>
<!-- zookeeper版本 -->
<zookeeper.version>3.4.6</zookeeper.version>
<!-- zkclient版本 -->
<zkclient.version>0.1</zkclient.version>
</properties>

<!-- 依赖 -->
<dependencies>
<dependency>
<groupId>cn.idea360</groupId>
<artifactId>dubbo-api</artifactId>
<version>1.0</version>
</dependency>
<!-- spring context -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${springframe.version}</version>
</dependency>
<!-- junit -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
</dependency>
<!-- log4j -->
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>${log4j.version}</version>
</dependency>
<!-- dubbo -->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>dubbo</artifactId>
<version>${dubbo.version}</version>
</dependency>
<!-- zookeeper -->
<dependency>
<groupId>org.apache.zookeeper</groupId>
<artifactId>zookeeper</artifactId>
<version>${zookeeper.version}</version>
</dependency>
<!-- zkclient -->
<dependency>
<groupId>com.github.sgroschupf</groupId>
<artifactId>zkclient</artifactId>
<version>${zkclient.version}</version>
</dependency>
</dependencies>

<!-- 构建配置 -->
<build>
<finalName>Provider</finalName>

<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<encoding>utf-8</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.1.0</version>
<configuration>
<archive>
<manifest>
<mainClass>cn.idea360.provider.Provider</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
</plugins>
</build>

</project>

在服务提供方实现接口

DemoServiceImpl.java

1
2
3
4
5
6
7
public class DemoServiceImpl implements DemoService {

@Override
public String sayHello(String name) {
return "Hello " + name;
}
}

用 Spring 配置声明暴露服务

dubbo/provider.xml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<?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-4.3.xsd
http://code.alibabatech.com/schema/dubbo
http://code.alibabatech.com/schema/dubbo/dubbo.xsd">

<!-- 提供方应用信息,用于计算依赖关系 -->
<dubbo:application name="dubbo-provider" />

<!-- 使用zookeeper广播注册中心暴露服务地址 -->
<dubbo:registry address="zookeeper://127.0.0.1:2181" client="zkclient" />

<!-- 用dubbo协议在20880端口暴露服务 -->
<dubbo:protocol name="dubbo" port="20880" />

<!-- 声明需要暴露的服务接口 -->
<dubbo:service interface="cn.idea360.api.DemoService" ref="demoService" />

<!-- 和本地bean一样实现服务 -->
<bean id="demoService" class="cn.idea360.provider.DemoServiceImpl" />
</beans>

加载 Spring 配置

Provider.java:

1
2
3
4
5
6
7
8
9
10
11
12
13
package cn.idea360.provider;

import org.springframework.context.support.ClassPathXmlApplicationContext;

public class Provider {
public static void main(String[] args) throws Exception {
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(new String[] {"dubbo/provider.xml"});
context.start();

System.out.println("服务已经启动...");
System.in.read(); // 按任意键退出
}
}

服务消费者

服务消费者maven

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>dubbo-demo</artifactId>
<groupId>cn.idea360</groupId>
<version>1.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>dubbo-consumer</artifactId>

<!-- 打包方式 -->
<packaging>jar</packaging>

<properties>
<!-- 源文件编码格式 -->
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<!-- jdk编译源码版本 -->
<jdk.compile.source.version>1.8</jdk.compile.source.version>
<!-- jdk编译目标版本 -->
<jdk.compile.target.version>1.8</jdk.compile.target.version>
<!-- springframework版本 -->
<springframe.version>5.1.5.RELEASE</springframe.version>
<!-- junit版本 -->
<junit.version>4.12</junit.version>
<!-- log4j版本 -->
<log4j.version>1.2.17</log4j.version>
<!-- dubbo版本 -->
<dubbo.version>2.5.3</dubbo.version>
<!-- zookeeper版本 -->
<zookeeper.version>3.4.6</zookeeper.version>
<!-- zkclient版本 -->
<zkclient.version>0.1</zkclient.version>
</properties>

<!-- 依赖 -->
<dependencies>
<dependency>
<groupId>cn.idea360</groupId>
<artifactId>dubbo-api</artifactId>
<version>1.0</version>
</dependency>
<!-- spring context -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${springframe.version}</version>
</dependency>
<!-- junit -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
</dependency>
<!-- log4j -->
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>${log4j.version}</version>
</dependency>
<!-- dubbo -->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>dubbo</artifactId>
<version>${dubbo.version}</version>
</dependency>
<!-- zookeeper -->
<dependency>
<groupId>org.apache.zookeeper</groupId>
<artifactId>zookeeper</artifactId>
<version>${zookeeper.version}</version>
</dependency>
<!-- zkclient -->
<dependency>
<groupId>com.github.sgroschupf</groupId>
<artifactId>zkclient</artifactId>
<version>${zkclient.version}</version>
</dependency>
</dependencies>

<!-- 构建配置 -->
<build>
<finalName>Consumer</finalName>
</build>

</project>

通过 Spring 配置引用远程服务

dubbo/consumer.xml:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
<?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-4.3.xsd
http://code.alibabatech.com/schema/dubbo
http://code.alibabatech.com/schema/dubbo/dubbo.xsd">

<!-- 消费方应用名,用于计算依赖关系,不是匹配条件,不要与提供方一样 -->
<dubbo:application name="dubbo-consumer" />

<!-- 使用zookeeper广播注册中心暴露发现服务地址 -->
<dubbo:registry address="zookeeper://127.0.0.1:2181" client="zkclient" />

<!-- 生成远程服务代理,可以和本地bean一样使用demoService -->
<dubbo:reference id="demoService" interface="cn.idea360.api.DemoService" />

<!-- 指定ip消费 -->
<dubbo:reference id="ipConsumerService" interface="cn.idea360.api.DemoService" url="dubbo://localhost:20880" />

</beans>

加载Spring配置,并调用远程服务

Consumer.java

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package cn.idea360.consumer;

import cn.idea360.api.DemoService;
import com.alibaba.dubbo.config.ApplicationConfig;
import com.alibaba.dubbo.config.ReferenceConfig;
import com.alibaba.dubbo.config.RegistryConfig;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
* @author cuishiying
*/
public class Consumer {

public static void main(String[] args) throws Exception {
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(new String[] {"dubbo/consumer.xml"});
context.start();

// 通过服务发现消费
DemoService demoService = (DemoService)context.getBean("demoService"); // 获取远程服务代理
String hello = demoService.sayHello("world"); // 执行远程方法
System.out.println("xml通过服务发现调用结果: " + hello); // 显示调用结果

// 通过ip直接消费
DemoService ipConsumerService = (DemoService)context.getBean("ipConsumerService"); // 获取远程服务代理
System.out.println("xml通过ip直连调用结果: " + ipConsumerService.sayHello("world")); // 显示调用结果

// 代码通过服务发现消费
ReferenceConfig<DemoService> reference = new ReferenceConfig<>();
reference.setApplication(new ApplicationConfig("testConsume"));
reference.setRegistry(new RegistryConfig("zookeeper://127.0.0.1:2181"));
reference.setInterface(DemoService.class);
System.out.println("code通过服务发现调用结果: " + reference.get().sayHello("world"));

// 代码通过ip消费
ReferenceConfig<DemoService> reference1 = new ReferenceConfig<>();
reference1.setApplication(new ApplicationConfig("testConsume"));
reference1.setUrl("dubbo://192.168.0.101:20880/cn.idea360.api.DemoService?anyhost=true&application=dubbo-provider&dubbo=2.5.3&interface=cn.idea360.api.DemoService&methods=sayHello&pid=66102&side=provider&timestamp=1669043877926");
reference1.setInterface(DemoService.class);
System.out.println("code通过ip调用结果: " + reference1.get().sayHello("world"));
}
}

说明: dubbo注册url可以从zk中获取, 例如示例demo中zk配置为

1
2
3
4
5
6
7
# dubbo基础信息
[zk: localhost:2181(CONNECTED) 7] ls /dubbo/cn.idea360.api.DemoService
[configurators, consumers, providers, routers]

# 服务接口注册信息
[zk: localhost:2181(CONNECTED) 10] ls /dubbo/cn.idea360.api.DemoService/providers
[dubbo://192.168.0.101:20880/cn.idea360.api.DemoService?anyhost=true&application=dubbo-provider&dubbo=2.5.3&interface=cn.idea360.api.DemoService&methods=sayHello&pid=66747&side=provider&timestamp=1669045212728]
  • 该接口需单独打包,在服务提供方和消费方共享

  • 对服务消费方隐藏实现

  • 也可以使用 IoC 注入

常用测试

pom.xml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>cn.idea360</groupId>
<artifactId>dubbo-consumer</artifactId>
<version>1.0</version>

<properties>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<dependencies>
<dependency>
<groupId>cn.easyliao</groupId>
<artifactId>webcall-config-api</artifactId>
<version>0.3.1.1</version>
</dependency>
<dependency>
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo</artifactId>
<version>2.7.18</version>
</dependency>
<dependency>
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo-dependencies-zookeeper</artifactId>
<version>2.7.18</version>
<type>pom</type>
</dependency>
<dependency>
<groupId>org.javassist</groupId>
<artifactId>javassist</artifactId>
<version>3.29.2-GA</version>
</dependency>
</dependencies>
</project>

consumer1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package cn.idea360.dubbo.consumer;

import cn.easyliao.webcall.config.service.api.ConfigLoadService;
import com.alibaba.fastjson.JSON;
import org.apache.dubbo.config.ApplicationConfig;
import org.apache.dubbo.config.ReferenceConfig;
import org.apache.dubbo.config.RegistryConfig;

/**
* @author cuishiying
*
* 参考: https://dubbo.apache.org/zh/docs/references/configuration/api/
*/
public class Consumer {

public static void main(String[] args) {
// 当前应用配置
ApplicationConfig application = new ApplicationConfig();
application.setName("demo-consumer");

// 连接注册中心配置
RegistryConfig registry = new RegistryConfig();
// nacos注册中心: nacos://127.0.0.1:8848/?username=nacos&password=nacos
registry.setAddress("zookeeper://10.10.10.208:2181");

// 注意:ReferenceConfig为重对象,内部封装了与注册中心的连接,以及与服务提供方的连接
// 引用远程服务
ReferenceConfig<ConfigLoadService> reference = new ReferenceConfig<>(); // 此实例很重,封装了与注册中心的连接以及与提供者的连接,请自行缓存,否则可能造成内存和连接泄漏
reference.setApplication(application);
reference.setRegistry(registry); // 多个注册中心可以用setRegistries()
reference.setInterface(ConfigLoadService.class);
reference.setGroup("test-prd18");
reference.setVersion("0.0.1");

ConfigLoadService configLoadService = reference.get();
System.out.println("code通过服务发现调用结果: " + JSON.toJSONString(configLoadService.getCompanyGlobalConfig(1)));
}
}

consumer2

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package cn.idea360.dubbo.consumer;

import cn.easyliao.webcall.config.service.api.ConfigLoadService;
import com.alibaba.fastjson.JSON;
import org.apache.dubbo.config.ReferenceConfig;
import org.apache.dubbo.config.RegistryConfig;
import org.apache.dubbo.config.bootstrap.DubboBootstrap;
import org.apache.dubbo.config.utils.ReferenceConfigCache;

/**
* @author cuishiying
*
* 参考: https://github.com/apache/dubbo/blob/master/dubbo-demo/dubbo-demo-api/dubbo-demo-api-consumer/src/main/java/org/apache/dubbo/demo/consumer/Application.java
*/
public class DubboBootstrapConsumer {

public static void main(String[] args) {

// 引用远程服务
ReferenceConfig<ConfigLoadService> reference = new ReferenceConfig<>();
reference.setInterface(ConfigLoadService.class);
reference.setGroup("test-prd18");
reference.setVersion("0.0.1");
// 设置url后将绕过注册中心
reference.setUrl("dubbo://10.10.10.217:7515/cn.easyliao.webcall.config.service.api.ConfigLoadService?xxx");

// 通过DubboBootstrap简化配置组装,控制启动过程
DubboBootstrap bootstrap = DubboBootstrap.getInstance();
bootstrap.application("demo-consumer") // 应用配置
.registry(new RegistryConfig("zookeeper://10.10.10.208:2181")) // 注册中心配置
.reference(reference) // 添加ReferenceConfig
.start(); // 启动Dubbo

// 和本地bean一样使用demoService
// 通过Interface获取远程服务接口代理,不需要依赖ReferenceConfig对象
ConfigLoadService configLoadService = ReferenceConfigCache.getCache().get(ConfigLoadService.class);
System.out.println("code通过服务发现调用结果: " + JSON.toJSONString(configLoadService.getCompanyGlobalConfig(1)));
}
}

consumer3

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
public class BaseConsumer {

private static final String ADREESS = "nacos://xxx.net:80/nacos?namespace=framework";
private static final String GROUP = "framework";
private static final String VERSION = "0.0.1";

protected static <T> T getProvider(Class<T> cls) {
// 当前应用配置
ApplicationConfig application = new ApplicationConfig();
application.setName("demo-consumer");

// 连接注册中心配置
RegistryConfig registry = new RegistryConfig();
registry.setAddress(ADREESS);
// registry.setAddress("zookeeper://10.10.10.208:2181");

// 注意:ReferenceConfig为重对象,内部封装了与注册中心的连接,以及与服务提供方的连接
// 引用远程服务
ReferenceConfig<T> reference = new ReferenceConfig<>(); // 此实例很重,封装了与注册中心的连接以及与提供者的连接,请自行缓存,否则可能造成内存和连接泄漏
reference.setApplication(application);
reference.setRegistry(registry); // 多个注册中心可以用setRegistries()
// reference.setUrl("dubbo://192.168.0.101:7529/cn.easyliao.webcall.config.service.api.ConfigCRUDService?accepts=2000&anyhost=true&application=webcall-config-tmp-service&application.start.time=2022-12-05 17:20:59&application.version=0.0.1&bean.name=ServiceBean:cn.easyliao.webcall.config.service.api.ConfigCRUDService&deprecated=false&dubbo=2.0.2&dynamic=true&easyliao.version=1.2.5.4&generic=false&group=test-prd18&interface=cn.easyliao.webcall.config.service.api.ConfigCRUDService&logger=log4j2&methods=registry,removeAll,pageQuery,removeById,find,get,count,refresh,update,insert,remove&payload=83886080&pid=32905&release=2.7.4.1&retries=0&revision=0.5.0.0&shutdown.timeout=3000&side=provider&threads=500&timeout=30000&timestamp=1670232060191&tracing=tracing&version=0.0.2");
reference.setInterface(cls);
reference.setGroup(GROUP);
reference.setVersion(VERSION);

return reference.get();
}
}

consumer4

如下配置文件,我们可以知道服务暴露在本地的7514端口

1
2
3
4
5
dubbo.application.name=crud-provider
dubbo.registry.address=10.10.10.215:2181
dubbo.registry.protocol=zookeeper
dubbo.protocol.name=dubbo
dubbo.protocol.port=7514

使用 telnet 命令进行访问,如下出现 Dubbo 字样时说明连接成功

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
➜  blog git:(master) ✗ telnet 10.10.10.215 7514
Trying 10.10.10.215...
Connected to 10.10.10.215.
Escape character is '^]'.

dubbo>ls
PROVIDER:
cn.easyliao.webcall.config.service.api.ConfigCRUDService
cn.easyliao.webcall.config.service.api.ConfigLoadService

dubbo>ls cn.easyliao.webcall.config.service.api.ConfigLoadService
cn.easyliao.webcall.config.service.api.ConfigLoadService (as provider):
getCompany
getCompanyGlobalConfig


dubbo>invoke cn.easyliao.webcall.config.service.api.ConfigLoadService.getCompany(1)
Use default service cn.easyliao.webcall.config.service.api.ConfigLoadService.
result: {"companyId":1,"companyName":"北京易聊科技有限公司","fax":"010-12345555","industry":"0","phoneNumber":"11111111","street":"朝阳区社区-同步","webSite":"http://www.easyliao555.cn"}
elapsed: 32 ms.
dubbo>

最后

本篇为dubbo学习入门笔记。欢迎大家关注微信公众号【当我遇上你】