Skip to content

Commit

Permalink
✨ 1.3.1
Browse files Browse the repository at this point in the history
  • Loading branch information
ChunMengLu committed May 8, 2022
1 parent c02a572 commit a2621b9
Show file tree
Hide file tree
Showing 4 changed files with 120 additions and 119 deletions.
9 changes: 5 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@
- :sparkles: mica-mqtt-broker 默认开启 http 和 basic auth。
- :sparkles: mica-mqtt server 添加服务端共享订阅接口,方便开源之夏学生参与。
- :sparkles: mica-mqtt server 添加 IMqttSessionListener。
- :sparkles: mica-mqtt server 统一 http 响应模型、优化 http 判断。
- :sparkles: mica-mqtt server publish 保留消息存储。
- :sparkles: mica-mqtt server 统一 http 响应模型、优化 http 请求判断。
- :sparkles: mica-mqtt server 优化 MqttHttpRoutes,添加获取所有路由的方法。
- :sparkles: mica-mqtt server 完善 Result 和 http api。
- :sparkles: mica-mqtt server http api 添加 endpoints 列表接口。
- :sparkles: mica-mqtt client 添加同步连接 connectSync 方法。
- :sparkles: mica-mqtt client 优化 bean 依赖。
- :bug: 重构 topic 匹配规则,提升性能减少内存占用,修复 gitee #I56BTC
- :arrow_up: 依赖升级
- :sparkles: mica-mqtt client 优化 bean 依赖,减少循环依赖可能性
- :bug: 重构 mqtt topic 匹配规则,提升性能减少内存占用,修复 gitee #I56BTC
- :arrow_up: spring boot、mica 版本升级

### v1.3.0 - 2022-04-17
- :sparkles: mica-mqtt mqtt-server 简化,默认多设备可以直接互相订阅和处理消息。
Expand Down
118 changes: 4 additions & 114 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
<dependency>
<groupId>net.dreamlu</groupId>
<artifactId>mica-mqtt-client-spring-boot-starter</artifactId>
<version>1.3.0</version>
<version>1.3.1</version>
</dependency>
```

Expand All @@ -66,7 +66,7 @@
<dependency>
<groupId>net.dreamlu</groupId>
<artifactId>mica-mqtt-server-spring-boot-starter</artifactId>
<version>1.3.0</version>
<version>1.3.1</version>
</dependency>
```

Expand All @@ -77,13 +77,14 @@
<dependency>
<groupId>net.dreamlu</groupId>
<artifactId>mica-mqtt-core</artifactId>
<version>1.3.0</version>
<version>1.3.1</version>
</dependency>
```

**配置详见**[mica-mqtt 使用文档](mica-mqtt-core/README.md)

## 文档
- [mica-mqtt 快速开始](example/README.md)
- [mica-mqtt-client-spring-boot-starter 使用文档](starter/mica-mqtt-client-spring-boot-starter/README.md)
- [mica-mqtt-server-spring-boot-starter 使用文档](starter/mica-mqtt-server-spring-boot-starter/README.md)
- [mica-mqtt 使用文档](mica-mqtt-core/README.md)
Expand All @@ -92,117 +93,6 @@
- [t-io 官方文档](https://www.tiocloud.com/doc/tio/85)
- [mqtt 协议文档](https://github.com/mcxiaoke/mqtt)

## 快速开始
查看 **mica-mqtt-example** 中有 `mqtt` 服务端和客户端演示代码, `main` 方法运行即可。

### 1. 启动 Server 端

运行 `example/mica-mqtt-example/src/main/java/net/dreamlu/iot/mqtt/server/MqttServerTest.java``main` 方法

控制台打印如下内容:

```text
2021-07-05 20:42:36,869 INFO server.TioServer -
|----------------------------------------------------------------------------------------|
| t-io site | https://www.tiocloud.com |
| t-io on gitee | https://gitee.com/tywo45/t-io |
| t-io on github | https://github.com/tywo45/t-io |
| t-io version | 3.7.3.v20210706-RELEASE |
| ---------------------------------------------------------------------------------------|
| TioConfig name | Mica-Mqtt-Server |
| Started at | 2021-07-05 20:42:36 |
| Listen on | 127.0.0.1:1883 |
| Main Class | net.dreamlu.iot.mqtt.server.MqttServerTest |
| Jvm start time | 2715ms |
| Tio start time | 16ms |
| Pid | 3588 |
|----------------------------------------------------------------------------------------|
2021-07-05 20:42:37,884 WARN server.MqttServer - Mqtt publish to all ChannelContext is empty.
```

`Mqtt publish to all ChannelContext is empty.` 通道上下文为空,即没有客户端。

```text
Mica-Mqtt-Server
├ 当前时间:1625489086843
├ 连接统计
│ ├ 共接受过连接数 :0
│ ├ 当前连接数 :0
│ ├ 异IP连接数 :0
│ └ 关闭过的连接数 :0
├ 消息统计
│ ├ 已处理消息 :0
│ ├ 已接收消息(packet/byte):0/0
│ ├ 已发送消息(packet/byte):0/0b
│ ├ 平均每次TCP包接收的字节数 :0.0
│ └ 平均每次TCP包接收的业务包 :0.0
└ IP统计时段
└ 没有设置ip统计时间
├ 节点统计
│ ├ clientNodes :0
│ ├ 所有连接 :0
│ ├ 绑定user数 :0
│ ├ 绑定token数 :0
│ └ 等待同步消息响应 :0
├ 群组
│ └ groupmap:0
└ 拉黑IP
└ []
2021-07-05 20:44:46,925 WARN server.ServerTioConfig - Mica-Mqtt-Server, 检查心跳, 共0个连接, 取锁耗时0ms, 循环耗时71ms, 心跳超时时间:120000ms
```

### 2. 启动 Client 端

运行 `example/mica-mqtt-example/src/main/java/net/dreamlu/iot/mqtt/client/MqttClientTest.java``main` 方法

控制台打印如下内容,表示客户端连接成功:
```text
2021-07-05 20:46:10,972 ERROR client.TioClient - closeds:0, connections:0
2021-07-05 20:46:10,972 INFO client.TioClient - [1]: curr:0, closed:0, received:(0p)(0b), handled:0, sent:(0p)(0b)
2021-07-05 20:46:12,566 INFO client.ConnectionCompletionHandler - connected to 127.0.0.1:1883
2021-07-05 20:46:12,586 INFO client.MqttClient - MqttClient reconnect send connect result:true
2021-07-05 20:46:12,630 INFO client.DefaultMqttClientProcessor - MqttClient connection succeeded!
2021-07-05 20:46:13,932 INFO client.MqttClientTest - /test/123 mica最牛皮
```

此时的 Server 端会打印出如下内容:

```text
2021-07-05 20:46:45,654 INFO server.MqttServerTest - subscribe: /test/client mica最牛皮
2021-07-05 20:46:46,926 WARN server.ServerTioConfig -
Mica-Mqtt-Server
├ 当前时间:1625489206923
├ 连接统计
│ ├ 共接受过连接数 :1
│ ├ 当前连接数 :1
│ ├ 异IP连接数 :1
│ └ 关闭过的连接数 :0
├ 消息统计
│ ├ 已处理消息 :20
│ ├ 已接收消息(packet/byte):20/584
│ ├ 已发送消息(packet/byte):37/935b
│ ├ 平均每次TCP包接收的字节数 :29.2
│ └ 平均每次TCP包接收的业务包 :1.0
└ IP统计时段
└ 没有设置ip统计时间
├ 节点统计
│ ├ clientNodes :1
│ ├ 所有连接 :1
│ ├ 绑定user数 :0
│ ├ 绑定token数 :0
│ └ 等待同步消息响应 :0
├ 群组
│ └ groupmap:0
└ 拉黑IP
└ []
2021-07-05 20:46:46,926 WARN server.ServerTioConfig - Mica-Mqtt-Server, 检查心跳, 共1个连接, 取锁耗时0ms, 循环耗时0ms, 心跳超时时间:120000ms
```

### 3. Client 接入 Aliyun MQTT 服务(示例)

详见 `example/mica-mqtt-example/src/main/java/net/dreamlu/iot/mqtt/aliyun/MqttClientTest.java`

## 参考vs借鉴
- [netty codec mqtt](https://github.com/netty/netty/tree/4.1/codec-mqtt)
- [jmqtt](https://github.com/Cicizz/jmqtt)
Expand Down
110 changes: 110 additions & 0 deletions example/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
## 快速开始
查看 **example/mica-mqtt-example** 中有 `mqtt` 服务端和客户端演示代码, `main` 方法运行即可。

### 1. 启动 Server 端

运行 `example/mica-mqtt-example/src/main/java/net/dreamlu/iot/mqtt/server/MqttServerTest.java``main` 方法

控制台打印如下内容:

```text
2021-07-05 20:42:36,869 INFO server.TioServer -
|----------------------------------------------------------------------------------------|
| t-io site | https://www.tiocloud.com |
| t-io on gitee | https://gitee.com/tywo45/t-io |
| t-io on github | https://github.com/tywo45/t-io |
| t-io version | 3.7.3.v20210706-RELEASE |
| ---------------------------------------------------------------------------------------|
| TioConfig name | Mica-Mqtt-Server |
| Started at | 2021-07-05 20:42:36 |
| Listen on | 127.0.0.1:1883 |
| Main Class | net.dreamlu.iot.mqtt.server.MqttServerTest |
| Jvm start time | 2715ms |
| Tio start time | 16ms |
| Pid | 3588 |
|----------------------------------------------------------------------------------------|
2021-07-05 20:42:37,884 WARN server.MqttServer - Mqtt publish to all ChannelContext is empty.
```

`Mqtt publish to all ChannelContext is empty.` 通道上下文为空,即没有客户端。

```text
Mica-Mqtt-Server
├ 当前时间:1625489086843
├ 连接统计
│ ├ 共接受过连接数 :0
│ ├ 当前连接数 :0
│ ├ 异IP连接数 :0
│ └ 关闭过的连接数 :0
├ 消息统计
│ ├ 已处理消息 :0
│ ├ 已接收消息(packet/byte):0/0
│ ├ 已发送消息(packet/byte):0/0b
│ ├ 平均每次TCP包接收的字节数 :0.0
│ └ 平均每次TCP包接收的业务包 :0.0
└ IP统计时段
└ 没有设置ip统计时间
├ 节点统计
│ ├ clientNodes :0
│ ├ 所有连接 :0
│ ├ 绑定user数 :0
│ ├ 绑定token数 :0
│ └ 等待同步消息响应 :0
├ 群组
│ └ groupmap:0
└ 拉黑IP
└ []
2021-07-05 20:44:46,925 WARN server.ServerTioConfig - Mica-Mqtt-Server, 检查心跳, 共0个连接, 取锁耗时0ms, 循环耗时71ms, 心跳超时时间:120000ms
```

### 2. 启动 Client 端

运行 `example/mica-mqtt-example/src/main/java/net/dreamlu/iot/mqtt/client/MqttClientTest.java``main` 方法

控制台打印如下内容,表示客户端连接成功:
```text
2021-07-05 20:46:10,972 ERROR client.TioClient - closeds:0, connections:0
2021-07-05 20:46:10,972 INFO client.TioClient - [1]: curr:0, closed:0, received:(0p)(0b), handled:0, sent:(0p)(0b)
2021-07-05 20:46:12,566 INFO client.ConnectionCompletionHandler - connected to 127.0.0.1:1883
2021-07-05 20:46:12,586 INFO client.MqttClient - MqttClient reconnect send connect result:true
2021-07-05 20:46:12,630 INFO client.DefaultMqttClientProcessor - MqttClient connection succeeded!
2021-07-05 20:46:13,932 INFO client.MqttClientTest - /test/123 mica最牛皮
```

此时的 Server 端会打印出如下内容:

```text
2021-07-05 20:46:45,654 INFO server.MqttServerTest - subscribe: /test/client mica最牛皮
2021-07-05 20:46:46,926 WARN server.ServerTioConfig -
Mica-Mqtt-Server
├ 当前时间:1625489206923
├ 连接统计
│ ├ 共接受过连接数 :1
│ ├ 当前连接数 :1
│ ├ 异IP连接数 :1
│ └ 关闭过的连接数 :0
├ 消息统计
│ ├ 已处理消息 :20
│ ├ 已接收消息(packet/byte):20/584
│ ├ 已发送消息(packet/byte):37/935b
│ ├ 平均每次TCP包接收的字节数 :29.2
│ └ 平均每次TCP包接收的业务包 :1.0
└ IP统计时段
└ 没有设置ip统计时间
├ 节点统计
│ ├ clientNodes :1
│ ├ 所有连接 :1
│ ├ 绑定user数 :0
│ ├ 绑定token数 :0
│ └ 等待同步消息响应 :0
├ 群组
│ └ groupmap:0
└ 拉黑IP
└ []
2021-07-05 20:46:46,926 WARN server.ServerTioConfig - Mica-Mqtt-Server, 检查心跳, 共1个连接, 取锁耗时0ms, 循环耗时0ms, 心跳超时时间:120000ms
```

### 3. Client 接入 Aliyun MQTT 服务(示例)

详见 `example/mica-mqtt-example/src/main/java/net/dreamlu/iot/mqtt/aliyun/MqttClientTest.java`
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

<properties>
<!-- mica-mqtt version -->
<revision>1.3.1-SNAPSHOT</revision>
<revision>1.3.1</revision>
<!-- java version -->
<java.version>1.8</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand Down

0 comments on commit a2621b9

Please sign in to comment.