README.md 4.0 KB
Newer Older
L
luxurong 已提交
1
![image](icon/smqtt.jpg)
L
luxurong 已提交
2

L
luxurong 已提交
3
## SMQTT是一款开源的MQTT消息代理Broker,
L
luxurong 已提交
4

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

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


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

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


L
luxurong 已提交
33
## main方式启动
L
luxurong 已提交
34 35 36

引入依赖
```markdown
L
luxurong 已提交
37 38 39 40 41
<dependency>
  <groupId>io.github.quickmsg</groupId>
  <artifactId>smqtt-core</artifactId>
  <version>1.0.3</version>
</dependency>
L
luxurong 已提交
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

```

阻塞式启动服务:

```markdown

        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();

```

非阻塞式启动服务:

```markdown

L
luxurong 已提交
67
        Bootstrap bootstrap = Bootstrap.builder()
L
luxurong 已提交
68 69 70
                .port(8555)
                .websocketPort(8999)
                .options(channelOptionMap -> {})
L
luxurong 已提交
71 72
                .highWaterMark(1000000)
                .lowWaterMark(1000)
L
luxurong 已提交
73 74 75
                .ssl(false)
                .sslContext(new SslContext("crt","key"))
                .isWebsocket(true)
L
luxurong 已提交
76
                .wiretap(true)
L
luxurong 已提交
77 78
                .httpOptions(Bootstrap.HttpOptions.builder().ssl(false).httpPort(62212).accessLog(true).build())
                .build()
L
luxurong 已提交
79 80
                .start().block();
        assert bootstrap != null;
L
luxurong 已提交
81
        // 关闭服务
L
luxurong 已提交
82
        bootstrap.shutdown();
L
luxurong 已提交
83 84 85 86

```


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


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

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

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

L
luxurong 已提交
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 135
```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 已提交
136
3. 启动服务
L
luxurong 已提交
137

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



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

L
luxurong 已提交
146
1. 准备配置文件conf.properties同上
L
luxurong 已提交
147 148

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

L
luxurong 已提交
153
2. 启动服务(默认1883端口)
L
luxurong 已提交
154 155

``` 
L
luxurong 已提交
156
# 启动服务
L
luxurong 已提交
157
docker run -it  -v <conf.properties路径>:/conf/config.properties  -p <宿主机 port>:<config配置端口默认1883> 1ssqq1lxr/smqtt
L
luxurong 已提交
158
```
L
luxurong 已提交
159

L
luxurong 已提交
160 161 162
###压测报告


L
luxurong 已提交
163

L
luxurong 已提交
164
## License
L
luxurong 已提交
165

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

L
luxurong 已提交
168
### 关注公众号,输入 `物联网`  扫码加入微信交流群
L
luxurong 已提交
169
![image](icon/icon.jpg)
L
luxurong 已提交
170 171 172