iot-mqtt-bridge描述文件與 mqtt 的消息中間件
iot-mqtt-bridge
feature:
- [x] 解析簡單 mqtt 消息存到 mysql
- [ ] 解析簡單 mqtt 消息存到 kafka
- [ ] 解析復(fù)雜消息
- [ ] 批處理存儲數(shù)據(jù)
- [ ] 自定義各種 handler
你只需要在 model.json 里定義一個描述文件,具體以含義看注釋,
然后配置 mqtt ,mysql 連接信息在 bridge.yml,
運(yùn)行 release/bin/server 啟動項目
就可以自動根據(jù)描述文件解析mqtt消息并存進(jìn)數(shù)據(jù)庫內(nèi)。
[
{
"name": "user", //"動態(tài)生成的類名”
"topic": "user_topic",
"clientId": "user_client",
"cleanSession": true,
"qos": 1,
"storeType": "mysql",
"fields": [{
"name": "id",
"type": "long", //"存數(shù)據(jù)庫字段的類型"
"index": 1,
"lenght": 8, //"截取多少個字節(jié)"
"offset": 2,
"idType": "auto" //”如果是auto就是用數(shù)據(jù)庫的自增,否則是截取到的數(shù)據(jù)“
},
{
"name": "loginLength",
"type": "int",
"index": 2,
"lenght": 2,
"isTransient": true //"不持久化到數(shù)據(jù)庫內(nèi)"
},
{
"name": "login",
"type": "byte[]",
"index": 3,
"dependsOn": 2 //"根據(jù)指定index的字段的值作為長度“
}
]
spring:
datasource:
driver-class-name: com.mysql.jdbc.Driver
url: jdbc:mysql://localhost:3306/mqtt_test
username:
password:
jdbc:
template:
prefix: t_
suffix: _test
insertGetId: false
logging:
config: logback.xml
bridge:
modelPath: model.json
mqtts:
- url: tcp://localhost:1883
username:
password:
keepAlive: 20
retained: false
reconnectAttemptsMax: -1
reconnectDelay: 10
models:
- user
評論
圖片
表情
