Skip to content

Commit 1c04473

Browse files
author
YunaiV
committed
Dubbo Admin 入门示例
1 parent 55d1b12 commit 1c04473

File tree

7 files changed

+30
-12
lines changed

7 files changed

+30
-12
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,8 @@
168168
* [《芋道 Spring Cloud 声明式调用 Feign 入门》](http://www.iocoder.cn/Spring-Cloud/Feign/?github) 对应 [labx-03](https://github.com/YunaiV/SpringBoot-Labs/tree/master/labx-03)
169169
* [《芋道 Spring Cloud 服务网关 Spring Cloud Gateway 入门》](http://www.iocoder.cn/Spring-Cloud/Spring-Cloud-Gateway/?github) 对应 [labx-08](https://github.com/YunaiV/SpringBoot-Labs/tree/master/labx-08)
170170
* [《芋道 Spring Cloud 链路追踪 SkyWalking 入门》](http://www.iocoder.cn/Spring-Cloud/SkyWalking/?github) 对应 [labx-14](https://github.com/YunaiV/SpringBoot-Labs/tree/master/labx-14)
171-
171+
* [《芋道 Dubbo Admin 快速入门》](http://www.iocoder.cn/Dubbo/Admin/?github)
172+
172173
# Spring Cloud 专栏
173174

174175
## 注册中心
@@ -308,9 +309,8 @@
308309
**[CAT](http://www.iocoder.cn/CAT/install/?github)**
309310
* [《芋道 Spring Boot 监控平台 CAT 入门》](http://www.iocoder.cn/Spring-Boot/CAT/?github)[「13. Dubbo 集成」](#)小节
310311

311-
TODO Dubbo-Admin
312-
313-
****
312+
**[Dubbo Admin](http://www.iocoder.cn/Dubbo/Admin/?github)**
313+
* [《芋道 Dubbo Admin 快速入门》](http://www.iocoder.cn/Dubbo/Admin/?github)
314314

315315
# 消息队列 MQ 专栏
316316

lab-30/lab-30-dubbo-annotations-demo/user-rpc-service-provider-02/src/main/resources/application.yaml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,12 @@ dubbo:
33
# Dubbo 应用配置
44
application:
55
name: user-service-provider # 应用名
6-
# Dubbo 注册中心配
6+
# Dubbo 注册中心配置
77
registry:
8-
address: zookeeper://127.0.0.1:2181 # 注册中心地址。个鞥多注册中心,可见 http://dubbo.apache.org/zh-cn/docs/user/references/registry/introduction.html 文档。
8+
address: zookeeper://127.0.0.1:2181 # 注册中心地址。配置多注册中心,可见 http://dubbo.apache.org/zh-cn/docs/user/references/registry/introduction.html 文档。
9+
# Dubbo 元数据中心配置
10+
metadata-report:
11+
address: zookeeper://127.0.0.1:2181 # 元数据中心地址。元数据中心的说明,可见 http://dubbo.apache.org/zh-cn/docs/user/references/metadata/introduction.html
912
# Dubbo 服务提供者协议配置
1013
protocol:
1114
port: -1 # 协议端口。使用 -1 表示随机端口。
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<http://www.iocoder.cn/Dubbo/Admin/github>

lab-67/lab-67-netty-demo/lab-67-netty-demo-common/src/main/java/cn/iocoder/springboot/lab67/nettycommondemo/codec/InvocationEncoder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ protected void encode(ChannelHandlerContext ctx, Invocation invocation, ByteBuf
2222
out.writeInt(content.length);
2323
// 写入内容
2424
out.writeBytes(content);
25-
logger.info("[decode][连接({}) 编码了一条消息({})]", ctx.channel().id(), invocation.toString());
25+
logger.info("[encode][连接({}) 编码了一条消息({})]", ctx.channel().id(), invocation.toString());
2626
}
2727

2828
}

lab-67/lab-67-netty-demo/lab-67-netty-demo-common/src/main/java/cn/iocoder/springboot/lab67/nettycommondemo/dispatcher/MessageDispatcher.java

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,17 @@
77
import io.netty.channel.SimpleChannelInboundHandler;
88
import org.springframework.beans.factory.annotation.Autowired;
99

10+
import java.util.concurrent.ExecutorService;
11+
import java.util.concurrent.Executors;
12+
1013
@ChannelHandler.Sharable
1114
public class MessageDispatcher extends SimpleChannelInboundHandler<Invocation> {
1215

1316
@Autowired
1417
private MessageHandlerContainer messageHandlerContainer;
1518

19+
private final ExecutorService executor = Executors.newFixedThreadPool(200);
20+
1621
@Override
1722
protected void channelRead0(ChannelHandlerContext ctx, Invocation invocation) {
1823
// 获得 type 对应的 MessageHandler 处理器
@@ -22,8 +27,15 @@ protected void channelRead0(ChannelHandlerContext ctx, Invocation invocation) {
2227
// 解析消息
2328
Message message = JSON.parseObject(invocation.getMessage(), messageClass);
2429
// 执行逻辑
25-
// noinspection unchecked
26-
messageHandler.execute(ctx.channel(), message);
30+
executor.submit(new Runnable() {
31+
32+
@Override
33+
public void run() {
34+
// noinspection unchecked
35+
messageHandler.execute(ctx.channel(), message);
36+
}
37+
38+
});
2739
}
2840

2941
}

lab-67/lab-67-netty-demo/lab-67-netty-demo-server/src/main/java/cn/iocoder/springboot/lab67/nettyserverdemo/messagehandler/auth/AuthRequestHandler.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,13 @@ public void execute(Channel channel, AuthRequest authRequest) {
2525
return;
2626
}
2727

28-
// 添加到 WebSocketUtil 中
28+
// ... 此处应有一段
29+
30+
// 将用户和 Channel 绑定
2931
// 考虑到代码简化,我们先直接使用 accessToken 作为 User
3032
nettyChannelManager.addUser(channel, authRequest.getAccessToken());
3133

32-
// 判断是否认证成功。这里,假装直接成功
34+
// 响应认证成功
3335
AuthResponse authResponse = new AuthResponse().setCode(0);
3436
channel.writeAndFlush(new Invocation(AuthResponse.TYPE, authResponse));
3537
}

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@
7777
<!-- <module>lab-64</module>-->
7878
<!-- <module>lab-65</module>-->
7979
<!-- <module>lab-66</module>-->
80+
<!-- <module>lab-67</module>-->
8081

8182
<!-- Spring Cloud 示例 -->
8283
<!-- <module>labx-01</module>-->
@@ -110,7 +111,6 @@
110111
<!-- <module>labx-28</module>-->
111112
<!-- <module>labx-29</module>-->
112113
<!-- <module>labx-30</module>-->
113-
<module>lab-67</module>
114114
</modules>
115115

116116
</project>

0 commit comments

Comments
 (0)