Browse Source

增加emqx配置等说明

xiwa 2 years ago
parent
commit
ce75f628ac

BIN
.DS_Store


BIN
data/components/.DS_Store


+ 185 - 0
iot-components/iot-emqx-component/emqx_rule_data.json

@@ -0,0 +1,185 @@
+{
+  "data":[
+    {
+      "rawsql":"SELECT\n  reason,\n  clientid,\n  username,\n  peername,\n  socketname\nFROM\n \"$events/client_connected\"",
+      "on_action_failed":"continue",
+      "metrics":[
+        {
+          "speed_max":0,
+          "speed_last5m":0,
+          "speed":0,
+          "passed":0,
+          "node":"emqx@127.0.0.1",
+          "no_result":0,
+          "matched":0,
+          "failed":0,
+          "exception":0
+        }
+      ],
+      "id":"rule:012980",
+      "for":[
+        "$events/client_connected"
+      ],
+      "enabled":true,
+      "description":"  连接",
+      "actions":[
+        {
+          "params":{
+            "target_topic":"/sys/client/connected",
+            "target_qos":1,
+            "payload_tmpl":"{\"reason\":\"${reason}\",\"clientid\":\"${clientid}\",\"username\":\"${username}\",\"peername\":\"${peername}\",\"socketname\":\"${socketname}\"}"
+          },
+          "name":"republish",
+          "metrics":[
+            {
+              "taken":0,
+              "success":0,
+              "node":"emqx@127.0.0.1",
+              "failed":0
+            }
+          ],
+          "id":"republish_16528854106752092",
+          "fallbacks":[
+
+          ]
+        }
+      ]
+    },
+    {
+      "rawsql":"SELECT\n  reason,\n  clientid,\n  username,\n  peername,\n  socketname\nFROM\n \"$events/client_disconnected\"",
+      "on_action_failed":"continue",
+      "metrics":[
+        {
+          "speed_max":0,
+          "speed_last5m":0,
+          "speed":0,
+          "passed":0,
+          "node":"emqx@127.0.0.1",
+          "no_result":0,
+          "matched":0,
+          "failed":0,
+          "exception":0
+        }
+      ],
+      "id":"rule:377397",
+      "for":[
+        "$events/client_disconnected"
+      ],
+      "enabled":true,
+      "description":"断开连接",
+      "actions":[
+        {
+          "params":{
+            "target_topic":"/sys/client/disconnected",
+            "target_qos":0,
+            "payload_tmpl":"{\"reason\":\"${reason}\",\"clientid\":\"${clientid}\",\"username\":\"${username}\",\"peername\":\"${peername}\",\"socketname\":\"${socketname}\"}"
+          },
+          "name":"republish",
+          "metrics":[
+            {
+              "taken":0,
+              "success":0,
+              "node":"emqx@127.0.0.1",
+              "failed":0
+            }
+          ],
+          "id":"republish_16528854190433372",
+          "fallbacks":[
+
+          ]
+        }
+      ]
+    },
+    {
+      "rawsql":"SELECT\n  clientid,\n  username,\n  topic,\n  qos\nFROM\n  \"$events/session_subscribed\"",
+      "on_action_failed":"continue",
+      "metrics":[
+        {
+          "speed_max":0,
+          "speed_last5m":0,
+          "speed":0,
+          "passed":0,
+          "node":"emqx@127.0.0.1",
+          "no_result":0,
+          "matched":0,
+          "failed":0,
+          "exception":0
+        }
+      ],
+      "id":"rule:758695",
+      "for":[
+        "$events/session_subscribed"
+      ],
+      "enabled":true,
+      "description":"子设备注册成功后,订阅topic: /sys/{productKey}/{deviceName}/c/#",
+      "actions":[
+        {
+          "params":{
+            "target_topic":"/sys/session/subscribed",
+            "target_qos":1,
+            "payload_tmpl":"{\"username\":\"${username}\",\"topic\":\"${topic}\",\"qos\":\"${qos}\",\"clientid\":\"${clientid}\"}"
+          },
+          "name":"republish",
+          "metrics":[
+            {
+              "taken":0,
+              "success":0,
+              "node":"emqx@127.0.0.1",
+              "failed":0
+            }
+          ],
+          "id":"republish_16530236276902029",
+          "fallbacks":[
+
+          ]
+        }
+      ]
+    },
+    {
+      "rawsql":"SELECT\n  clientid,\n  username,\n  topic,\n  qos\nFROM\n  \"$events/session_unsubscribed\"",
+      "on_action_failed":"continue",
+      "metrics":[
+        {
+          "speed_max":0,
+          "speed_last5m":0,
+          "speed":0,
+          "passed":0,
+          "node":"emqx@127.0.0.1",
+          "no_result":0,
+          "matched":0,
+          "failed":0,
+          "exception":0
+        }
+      ],
+      "id":"rule:514503",
+      "for":[
+        "$events/session_unsubscribed"
+      ],
+      "enabled":true,
+      "description":"",
+      "actions":[
+        {
+          "params":{
+            "target_topic":"/sys/session/unsubscribed",
+            "target_qos":0,
+            "payload_tmpl":"{\"username\":\"${username}\",\"topic\":\"${topic}\",\"qos\":\"${qos}\",\"clientid\":\"${clientid}\"}"
+          },
+          "name":"republish",
+          "metrics":[
+            {
+              "taken":0,
+              "success":0,
+              "node":"emqx@127.0.0.1",
+              "failed":0
+            }
+          ],
+          "id":"republish_16530237303922829",
+          "fallbacks":[
+
+          ]
+        }
+      ]
+    }
+  ],
+  "code":0
+}

+ 6 - 0
iot-components/iot-emqx-component/readme.md

@@ -0,0 +1,6 @@
+## EMQX配置
+
+接入emqx需要在EMQX的规则引擎界面新增订阅、取消订阅、连接、断开连接的消息转发。
+
+配置内容见:emqx_rule_data.json
+

+ 1 - 0
iot-standalone/src/main/resources/application-dev.yml

@@ -22,6 +22,7 @@ spring:
     password: 123456
     driverClassName: org.h2.Driver
 
+  #注: 切换数据库时需要将项目根目录中的.init文件删除再重启
   ## 内置h2 web console设置
     platform: h2
   h2:

+ 75 - 0
iot-standalone/src/main/resources/application-mysql.yml

@@ -0,0 +1,75 @@
+server:
+  port: 8086
+
+spring:
+  servlet:
+    multipart:
+      enabled: true
+      max-file-size: 10MB
+      max-request-size: 12MB
+
+  #注: 切换数据库时需要将项目根目录中的.init文件删除再重启
+  # <<==========mysql配置开始==============
+  datasource:
+    url: jdbc:mysql://127.0.0.1:3306/iotkit?useUnicode=true&characterEncoding=UTF-8&serverTimezone=UTC&useSSL=false
+    driverClassName: com.mysql.cj.jdbc.Driver
+    username: root
+    password: 123456
+    validationQuery: SELECT 1
+    testOnBorrow: true
+  jpa:
+    database: MySQL
+    database-platform: org.hibernate.dialect.MySQL5InnoDBDialect
+#    show-sql: true
+    hibernate:
+      ddl-auto: update
+    properties:
+      hibernate:
+        format_sql: true
+  # ============mysql配置结束============>>
+
+  elasticsearch:
+    rest:
+      #使用内置es的配置
+      uris: http://127.0.0.1:9200
+      username:
+      password:
+      connection-timeout: 10s
+
+  redis:
+    #使用内置redis的配置
+    host: 127.0.0.1
+    port: 6379
+    database: 0
+    password:
+
+  mvc:
+    pathmatch:
+      matching-strategy: ant_path_matcher
+
+#图片存储用的是阿里云oss,如果需要上传产品图片才需要配置
+aliyun:
+  bucketId: iotkit-img
+  endpoint: oss-cn-shenzhen.aliyuncs.com
+  accessKeyId: 填写阿里云accessKeyId
+  accessKeySecret: 填写阿里云accessKeySecret
+
+sa-token:
+  # token名称 (同时也是cookie名称)
+  token-name: token
+  # token有效期,单位s 默认30天, -1代表永不过期
+  timeout: 2592000
+  # token临时有效期 (指定时间内无操作就视为token过期) 单位: 秒
+  activity-timeout: -1
+  # 是否允许同一账号并发登录 (为true时允许一起登录, 为false时新登录挤掉旧登录)
+  is-concurrent: true
+  # 在多人登录同一账号时,是否共用一个token (为true时所有登录共用一个token, 为false时每次登录新建一个token)
+  is-share: false
+  # token风格
+  token-style: uuid
+  # 是否输出操作日志
+  is-log: false
+
+#认证中心地址
+oauth2:
+  auth-server-url: http://127.0.0.1:8086

+ 1 - 0
iot-standalone/src/main/resources/application.yml

@@ -8,6 +8,7 @@ spring:
       max-file-size: 10MB
       max-request-size: 12MB
 
+  #注: 切换数据库时需要将项目根目录中的.init文件删除再重启
   # <<=======内置H2数据库连接设置开始==========
   jpa:
 #    show-sql: true