Переглянути джерело

add docs for mqtt msg bus

RockyJin 5 роки тому
батько
коміт
db96df7cbb

+ 50 - 1
docs/en_US/rules/sinks/edgex.md

@@ -11,6 +11,24 @@ The action is used for publish output message into EdgeX message bus.
 | contentType   | true     | The content type of message to be published. If not specified, then use the default value ``application/json``. |
 | metadata      | true     | The property is a field name that allows user to specify a field name of SQL  select clause,  the field name should use ``meta(*) AS xxx``  to select all of EdgeX metadata from message. |
 | deviceName    | true     | Allows user to specify the device name in the event structure that are sent from Kuiper. |
+| type          | true     | The message bus type, two types of message buses are supported, ``zero`` or ``mqtt``, and ``zero`` is the default value. |
+| optional      | true     | If ``mqtt`` message bus type is specified, then some optional values can be specified. Please refer to below for supported optional supported configurations. |
+
+Please notice that all of values in optional are **<u>string type</u>**, so values for these configurations should be string - such as ``KeepAlive: "5000"``. Below optional configurations are supported, please check MQTT specification for the detailed information.
+
+- optional
+  - ClientId
+  - Username
+  - Password
+  - Qos
+  - KeepAlive
+  - Retained
+  - ConnectionPayload
+  - CertFile
+  - KeyFile
+  - CertPEMBlock
+  - KeyPEMBlock
+  - SkipCertVerify
 
 ## Examples
 
@@ -120,4 +138,35 @@ Please notice that,
 - For the reading that can NOT be found in original message,  the metadata will not be set.  Such as metadata of ``t1`` in the sample will fill with default value that generated by Kuiper. 
 - If your SQL has aggregated function, then it does not make sense to keep these metadata, but Kuiper will still fill with metadata from a particular message in the time window. For example, with following SQL, 
 ```SELECT avg(temperature) AS temperature, meta(*) AS edgex_meta FROM ... GROUP BY TUMBLINGWINDOW(ss, 10)```. 
-In this case, there are possibly several messages in the window, the metadata value for ``temperature`` will be filled with value from 1st message that received from bus.
+In this case, there are possibly several messages in the window, the metadata value for ``temperature`` will be filled with value from 1st message that received from bus.
+
+## Send result to MQTT message bus
+
+Below is a rule that send analysis result to MQTT message bus, please notice how to specify ``ClientId`` in ``optional`` configuration.
+
+```json
+{
+  "id": "rule1",
+  "sql": "SELECT meta(*) AS edgex_meta, temperature, humidity, humidity*2 as h1 FROM demo WHERE temperature = 20",
+  "actions": [
+    {
+      "edgex": {
+        "protocol": "tcp",
+        "host": "127.0.0.1",
+        "port": 1883,
+        "topic": "result",
+        "type": "mqtt",
+        "metadata": "edgex_meta",
+        "contentType": "application/json",
+        "optional": {
+        	"ClientId": "edgex_message_bus_001"
+        }
+      }
+    },
+    {
+      "log":{}
+    }
+  ]
+}
+```
+

+ 25 - 0
docs/en_US/rules/sources/edgex.md

@@ -83,6 +83,31 @@ The topic name of EdgeX message bus,  default value is ``events``.
 
 The base service address for getting value descriptors, the value of ``serviceServer`` will be concatenated to ``/api/v1/valuedescriptor`` to get all of value descriptors of EdgeX server.
 
+## type
+
+The EdgeX message bus type, currently two types of message buses are supported. If specified other values, then will use the default ``zero`` value.
+
+- ``zero``: Use ZeroMQ as EdgeX message bus. 
+- ``mqtt``: Use the MQTT broker as EdgeX message bus.
+
+## optional
+
+If MQTT message bus is used, some other optional configurations can be specified. Please notice that all of values in optional are **<u>string type</u>**, so values for these configurations should be string - such as ``KeepAlive: "5000"``. Below optional configurations are supported, please check MQTT specification for the detailed information.
+
+- ClientId
+
+- Username
+- Password
+- Qos
+- KeepAlive
+- Retained
+- ConnectionPayload
+- CertFile
+- KeyFile
+- CertPEMBlock
+- KeyPEMBlock
+- SkipCertVerify
+
 ## Override the default settings
 
 In some cases, maybe you want to consume message from multiple topics from message bus.  Kuiper supports to specify another configuration, and use the ``CONF_KEY`` to specify the newly created key when you create a stream.

+ 50 - 1
docs/zh_CN/rules/sinks/edgex.md

@@ -11,6 +11,24 @@
 | contentType | true     | 发布消息的内容类型,如未指定,使用缺省值 ``application/json``. |
 | metadata    | true     | 该属性为一个字段名称,该字段是 SQL SELECT 子句的一个字段名称,这个字段应该类似于 ``meta(*) AS xxx`` ,用于选出消息中所有的 EdgeX 元数据. |
 | deviceName  | true     | 允许用户指定设备名称,该名称将作为从 Kuiper 中发送出来的 Event 结构体的设备名称. |
+| type          | true     | 消息总线类型,目前支持两种类型的消息总线, ``zero`` 或者 ``mqtt``,其中 ``zero`` 为缺省类型。 |
+| optional      | true     | 如果指定了 ``mqtt`` 消息总线,那么还可以指定一下可选的值。请参考以下可选的支持的配置类型。 |
+
+请注意,所有在可选的配置项里指定的值都必须为**<u>字符类型</u>**,因此这里出现的所有的配置应该是字符类型的 - 例如 ``KeepAlive: "5000"``。以下为支持的可选的配置列表,您可以参考 MQTT 协议规范来获取更详尽的信息。
+
+- optional
+  - ClientId
+  - Username
+  - Password
+  - Qos
+  - KeepAlive
+  - Retained
+  - ConnectionPayload
+  - CertFile
+  - KeyFile
+  - CertPEMBlock
+  - KeyPEMBlock
+  - SkipCertVerify
 
 ## 例子
 
@@ -124,4 +142,35 @@
 - 对于在原有消息中无法找到的 reading,元数据将不会被设置。如例子中的``t1`` 的元数据被设置为 Kuiper 产生的缺省值。
 - 如果你的 SQL 包含了聚合函数,那保留原有的元数据就没有意义,但是 Kuiper 还是会使用时间窗口中的某一条记录的元数据。例如,在下面的 SQL 里,
 ```SELECT avg(temperature) AS temperature, meta(*) AS edgex_meta FROM ... GROUP BY TUMBLINGWINDOW(ss, 10)```. 
-这种情况下,在时间窗口中可能有几条数据,Kuiper 会使用窗口中的第一条数据的元数据来填充 ``temperature`` 的元数据。
+这种情况下,在时间窗口中可能有几条数据,Kuiper 会使用窗口中的第一条数据的元数据来填充 ``temperature`` 的元数据。
+
+## 结果发布到 MQTT 消息总线
+
+以下是将分析结果发送到 MQTT 消息总线的规则,请注意在``optional`` 中是如何指定 ``ClientId`` 的。
+
+```json
+{
+  "id": "rule1",
+  "sql": "SELECT meta(*) AS edgex_meta, temperature, humidity, humidity*2 as h1 FROM demo WHERE temperature = 20",
+  "actions": [
+    {
+      "edgex": {
+        "protocol": "tcp",
+        "host": "127.0.0.1",
+        "port": 1883,
+        "topic": "result",
+        "type": "mqtt",
+        "metadata": "edgex_meta",
+        "contentType": "application/json",
+        "optional": {
+        	"ClientId": "edgex_message_bus_001"
+        }
+      }
+    },
+    {
+      "log":{}
+    }
+  ]
+}
+```
+

+ 25 - 0
docs/zh_CN/rules/sources/edgex.md

@@ -83,6 +83,31 @@ EdgeX 消息总线上监听的主题名称,缺省为 ``events``.
 
 访问 value descriptors 的基础服务地址,配置项 ``serviceServer`` 的值与 ``/api/v1/valuedescriptor`` 拼接后,用于获取 EdgeX 服务器上定义的所有 value descriptors。
 
+## type
+
+EdgeX 消息总线类型,目前支持两种消息总线。如果指定了错误的消息总线类型,那么会使用缺省 ``zero`` 类型。
+
+- ``zero``:使用 ZeroMQ 类型的消息总线 
+- ``mqtt``:使用 MQTT 服务器作为消息总线
+
+## optional
+
+如果使用了 MQTT 消息总线,还可以指定别的一些可选配置项。请注意,所有在可选的配置项里指定的值都必须为**<u>字符类型</u>**,因此这里出现的所有的配置应该是字符类型的 - 例如 ``KeepAlive: "5000"``。以下为支持的可选的配置列表,您可以参考 MQTT 协议规范来获取更详尽的信息。
+
+- ClientId
+
+- Username
+- Password
+- Qos
+- KeepAlive
+- Retained
+- ConnectionPayload
+- CertFile
+- KeyFile
+- CertPEMBlock
+- KeyPEMBlock
+- SkipCertVerify
+
 ## 重载缺省设置
 
 在某些情况下,你可能想消费来自于多个主题的数据。Kuiper 支持指定别的配置,并且在创建流定义的时候使用 ``CONF_KEY`` 来指定新的配置。

+ 2 - 1
etc/sources/edgex.yaml

@@ -5,7 +5,8 @@ default:
   port: 5563
   topic: events
   serviceServer: http://localhost:48080
-#  Below is optional configurations settings for MQTT
+#  Below is optional configurations settings for mqtt
+#  type: mqtt
 #  optional:
 #    ClientId: "client1"
 #    Username: "user1"