簡介:
SMQTT基于reactor-netty(spring-webflux底層依賴) 開發,底層采用Reactor3反應堆模型,支援單機部署,支援容器化部署,具備低延遲,高吞吐量,支援百萬TCP連接配接,同時支援多種協定互動,是一款非常優秀的消息中間件!
功能特性:
- 消息品質等級實作(支援qos0,qos1,qos2)
- topicFilter支援
- topic分級(test/test)
- +支援(單層比對)
- *支援(多層比對)
- 會話消息
- 預設記憶體存儲
- 支援持久化(redis/db)
- 保留消息
- 預設記憶體存儲
- 支援持久化(redis/db)
- 遺囑消息
- 裝置掉線時候觸發
- 用戶端認證
- 支援spi注入外部認證
- tls加密
- 支援tls加密(mqtt端口/http端口)
- websocket協定支援x
- 使用mqtt over websocket
- http協定互動
- 支援http接口推送消息
- 支援spi擴充http接口
- SPI接口擴充支援
- 消息管理接口(會話消息/保留消息管理)
- 通道管理接口 (管理系統的用戶端連接配接)
- 認證接口 (用于自定義外部認證)
- 攔截器 (使用者自定義攔截消息)
- 叢集支援(gossip協定實作)
- 容器化支援
- 預設鏡像最新tag: 1ssqq1lxr/smqtt
- 持久化支援(session 保留消息)
- 規則引擎支援
- 支援springboot starter啟動
- 管理背景
- 請參考smqtt文檔如何啟動管理背景
- grafana監控內建
- 支援influxdb
- 支援prometheus
- ACL權限管理
- 對裝置、資通路授權
- 認證子產品
- 支援http
- 支援匿名
- 支援固定密碼
- 支援sql
嘗試一下
大家不要惡意連結,謝謝!
管理 | 說明 | 其他 |
121.40.92.152:1883 | mqtt端口 | 使用者名:smqtt 密碼:smqtt |
121.40.92.152:18888 | mqtt over websocket | 使用者名:smqtt 密碼:smqtt |
http://121.40.92.152:60000/smqtt/admin | 管理背景 | 使用者名:smqtt 密碼:smqtt |
啟動方式
main方式啟動
引入依賴
<!--smqtt依賴 -->
<dependency>
<groupId>io.github.quickmsg</groupId>
<artifactId>smqtt-core</artifactId>
<version>${Latest version}</version>
</dependency>
<!--叢集依賴 -->
<dependency>
<artifactId>smqtt-registry-scube</artifactId>
<groupId>io.github.quickmsg</groupId>
<version>${Latest version}</version>
</dependency>
<!--管理ui依賴 -->
<dependency>
<artifactId>smqtt-ui</artifactId>
<groupId>io.github.quickmsg</groupId>
<version>${Latest version}</version>
</dependency>
- 阻塞式啟動服務:
Bootstrap.builder()
.rootLevel(Level.INFO)
.websocketConfig(
BootstrapConfig.WebsocketConfig
.builder()
.enable(false)
.path("/mqtt")
.port(8888)
.build()
)
.tcpConfig(
BootstrapConfig
.TcpConfig
.builder()
.port(1883)
.ssl(SslContext.builder().enable(false).build())
.build())
.httpConfig(
BootstrapConfig
.HttpConfig
.builder()
.enable(false)
.accessLog(true)
.admin(BootstrapConfig.HttpAdmin.builder().enable(true).username("smqtt").password("smqtt").build())
.build())
.clusterConfig(
BootstrapConfig.
ClusterConfig
.builder()
.enable(false)
.namespace("smqtt")
.node("node-1")
.port(7773)
.url("127.0.0.1:7771,127.0.0.1:7772").
build())
.build()
.startAwait();
- 非阻塞式啟動服務:
Bootstrap bootstrap = Bootstrap.builder()
.rootLevel(Level.INFO)
.websocketConfig(
BootstrapConfig.WebsocketConfig
.builder()
.enable(false)
.path("/mqtt")
.port(8888)
.build()
)
.tcpConfig(
BootstrapConfig
.TcpConfig
.builder()
.port(1883)
.ssl(SslContext.builder().enable(false).build())
.build())
.httpConfig(
BootstrapConfig
.HttpConfig
.builder()
.enable(false)
.accessLog(true)
.admin(BootstrapConfig.HttpAdmin.builder().enable(true).username("smqtt").password("smqtt").build())
.build())
.clusterConfig(
BootstrapConfig.
ClusterConfig
.builder()
.enable(false)
.namespace("smqtt")
.node("node-1")
.port(7773)
.url("127.0.0.1:7771,127.0.0.1:7772").
build())
.build()
.start().block();
jar方式
- 下載下傳源碼 mvn compile package -Dmaven.test.skip=true -P jar,web
在smqtt-bootstrap/target目錄下生成jar
- 準備配置檔案 config.yaml
- config.yaml
- 啟動服務
java -jar smqtt-bootstrap-1.0.1-SNAPSHOT.jar <config.yaml路徑>
docker 方式
拉取鏡像
# 拉取docker鏡像位址
docker pull 1ssqq1lxr/smqtt:latest
啟動鏡像預設配置
# 啟動服務
docker run -it -p 1883:1883 1ssqq1lxr/smqtt
啟動鏡像使用自定義配置(同上準備配置檔案config.yaml)
# 啟動服務
docker run -it -v <配置檔案路徑目錄>:/conf -p 1883:1883 -p 1999:1999 1ssqq1lxr/smqtt
springboot方式
- 引入依賴
- <dependency> <groupId>io.github.quickmsg</groupId> <artifactId>smqtt-spring-boot-starter</artifactId> <version>${Latest version >= 1.0.8}</version> </dependency>
- 啟動類Application上添加注解 @EnableMqttServer
- 配置application.yml檔案
- properties也支援,但是需要自己轉換,沒有提供demo檔案
- config.yaml
- 啟動springboot服務服務即可
- 如果引入的是spring-boot-starter-parent的管理包,如果啟動報錯,則需要添加以下依賴
<dependency>
<groupId>io.projectreactor</groupId>
<artifactId>reactor-core</artifactId>
<version>3.4.9</version>
</dependency>
<dependency>
<groupId>io.projectreactor.netty</groupId>
<artifactId>reactor-netty</artifactId>
<version>1.0.10</version>
</dependency>
官網位址
https://www.smqtt.cc/
wiki位址
https://wiki.smqtt.cc/
管理背景
監控頁面
Mqtt監控
Jvm監控
Netty監控
結束語
目前市面上主流MQTT協定的broker選型EMQX,EMQX分商業版和社群版,社群版被閹割,用商業版又是一筆很大開銷,此款國産開源的MQTT Broker具備很多商業案例,性能良好,值得選型使用!
開源分享不易,感謝大家的支援,多關注,點贊。後續也會分享更多的幹貨和技術資訊,您的閱讀就是對小編的支援,再次感謝各位老鐵!