README.md 4.2 KB
Newer Older
L
luxurong 已提交
1
## SMQTT是一款开源的MQTT消息代理Broker,
L
luxurong 已提交
2

L
luxurong 已提交
3
SMQTT基于Netty开发,底层采用Reactor3反应堆模型,支持单机部署,支持容器化部署,具备低延迟,高吞吐量,支持百万TCP连接,同时支持多种协议交互,是一款非常优秀的消息中间件!
L
luxurong 已提交
4
## smqtt目前拥有的功能如下:
L
luxurong 已提交
5 6 7 8 9 10 11

1.  消息质量等级实现(支持qos0,qos1,qos2)
2.  会话消息
3.  保留消息
4.  遗嘱消息
5.  客户端认证
6.  tls加密
L
luxurong 已提交
12 13 14
7.  websocket协议支持
8.  http协议交互
9.  SPI接口扩展支持
L
luxurong 已提交
15 16 17 18 19 20 21 22
    - 消息管理接口(会话消息/保留消息管理)
    - 通道管理接口 (管理系统的客户端连接)
    - 认证接口 (用于自定义外部认证)
    - 拦截器  (用户自定义拦截消息)
10. 集群支持(gossip协议实现)
11. 容器化支持 


L
luxurong 已提交
23
## 后面规划项目
L
luxurong 已提交
24 25 26 27 28 29 30

1. 规则引擎
2. Web管理系统
3. 监控系统
4. 协议桥接agent(用户其他协议与broker之间交互)


L
luxurong 已提交
31
## main方式启动
L
luxurong 已提交
32 33 34

引入依赖
```markdown
L
luxurong 已提交
35 36 37 38 39
<dependency>
  <groupId>io.github.quickmsg</groupId>
  <artifactId>smqtt-core</artifactId>
  <version>1.0.3</version>
</dependency>
L
luxurong 已提交
40 41 42 43 44 45 46

```

阻塞式启动服务:

```markdown

L
README  
luxurong 已提交
47 48 49 50 51 52 53 54 55 56 57
 Bootstrap.builder()
       .port(8555)
       .websocketPort(8999)
       .options(channelOptionMap -> {})
       .ssl(false)
       .sslContext(new SslContext("crt","key"))
       .isWebsocket(true)
       .wiretap(false)
       .httpOptions(Bootstrap.HttpOptions.builder().ssl(false).httpPort(62212).accessLog(true).build())
       .build()
        .startAwait();
L
luxurong 已提交
58 59 60 61 62 63 64

```

非阻塞式启动服务:

```markdown

L
README  
luxurong 已提交
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81
 
 Bootstrap bootstrap = 
        Bootstrap.builder()
       .port(8555)
       .websocketPort(8999)
       .options(channelOptionMap -> {})
       .ssl(false)
       .sslContext(new SslContext("crt","key"))
       .isWebsocket(true)
       .wiretap(false)
       .httpOptions(Bootstrap.HttpOptions.builder().ssl(false).httpPort(62212).accessLog(true).build())
       .build()
       .start().block();

assert bootstrap != null;
 // 关闭服务
 bootstrap.shutdown();
L
luxurong 已提交
82 83 84 85

```


L
luxurong 已提交
86
## jar方式
L
luxurong 已提交
87 88


L
luxurong 已提交
89
1. 下载源码 mvn compile package <smqtt-bootstrap module> -P jar
L
luxurong 已提交
90

L
luxurong 已提交
91 92 93
```markdown
  在smqtt-bootstrap/target目录下生成jar
```
L
luxurong 已提交
94

1ssqq1lxr's avatar
1ssqq1lxr 已提交
95
2. 准备配置文件 config.properties
L
luxurong 已提交
96

L
luxurong 已提交
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134
```markdown
    
    # 开启tcp端口
    smqtt.tcp.port=1883
    # 高水位
    smqtt.tcp.lowWaterMark=4000000
    # 低水位
    smqtt.tcp.highWaterMark=80000000
    # 开启ssl加密
    smqtt.tcp.ssl=false
    # 证书crt smqtt.tcp.ssl.crt =
    # 证书key smqtt.tcp.ssl.key =
    # 开启日志
    smqtt.tcp.wiretap=false
    # boss线程
    smqtt.tcp.bossThreadSize=4;
    # work线程
    smqtt.tcp.workThreadSize=8;
    # websocket端口
    smqtt.websocket.port=8999;
    # websocket开启
    smqtt.websocket.enable=true;
    # smqtt用户
    smqtt.tcp.username=smqtt;
    # smqtt密码
    smqtt.tcp.password=smqtt;
    # 开启http
    smqtt.http.enable=true;
    # 开启http端口
    smqtt.http.port=1999;
    # 开启http日志
    smqtt.http.accesslog=true;
    # 开启ssl
    smqtt.http.ssl.enable=false;
    # smqtt.http.ssl.crt =;
    # smqtt.http.ssl.key;
  ```

1ssqq1lxr's avatar
1ssqq1lxr 已提交
135
3. 启动服务
L
luxurong 已提交
136

L
luxurong 已提交
137 138 139
```markdown
  java -jar smqtt-bootstrap-1.0.1-SNAPSHOT.jar <conf.properties路径>
```
L
luxurong 已提交
140 141 142



L
luxurong 已提交
143
## docker 方式
L
luxurong 已提交
144

L
luxurong 已提交
145 146

拉取镜像
L
luxurong 已提交
147 148

``` 
L
luxurong 已提交
149
# 拉取docker镜像地址
L
luxurong 已提交
150 151 152
docker pull 1ssqq1lxr/smqtt:latest
```

L
luxurong 已提交
153
启动镜像默认配置
L
luxurong 已提交
154 155

``` 
L
luxurong 已提交
156
# 启动服务
L
luxurong 已提交
157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177
docker run -it  -p 1883:1883 1ssqq1lxr/smqtt
```

启动镜像使用自定义配置( 准备配置文件conf.properties)


``` 
# 启动服务
docker run -it  -v <配置文件路径目录>:/conf -p 1883:1883  -p 1999:1999 1ssqq1lxr/smqtt
```


## 测试服务(启动http端口)

- 启动客户端订阅主题 test/+

- 使用http接口推送mqtt消息

``` 
# 推送消息
curl -H "Content-Type: application/json" -X POST -d '{"topic": "test/teus", "qos":2, "retain":true, "message":"我来测试保留消息3" }' "http://localhost:1999/smqtt/publish"
L
luxurong 已提交
178
```
L
luxurong 已提交
179

L
luxurong 已提交
180 181 182 183 184


## 其他功能文档尚未完善,有兴趣同学可以加我微信群!


L
luxurong 已提交
185 186 187
###压测报告


L
luxurong 已提交
188

L
luxurong 已提交
189
## License
L
luxurong 已提交
190

L
luxurong 已提交
191
[Apache License, Version 2.0](https://github.com/quickmsg/smqtt/blob/main/LICENSE)
L
luxurong 已提交
192

L
luxurong 已提交
193 194 195
### 添加微信号`Lemon877164954`,拉入smqtt官方交流群
### 加入qq群 `700152283` 
### 麻烦关注下公众号!
L
luxurong 已提交
196

L
luxurong 已提交
197
![image](icon/icon.jpg)
L
luxurong 已提交
198