Skip to content

Commit a9c2e43

Browse files
committed
Merge remote-tracking branch 'origin/release-5.9' into 20250319-r59-license-transformation
2 parents 6d75439 + 7d6b2d7 commit a9c2e43

16 files changed

+338
-27
lines changed

dir.yaml

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -298,22 +298,22 @@
298298
- data-integration/rule-sql-builtin-functions
299299
- data-integration/rule-sql-jq
300300
# - data-integration/rule-sql-user-defined-function
301-
- title_en: Schema Registry
302-
title_cn: Schema
303-
path: data-integration/schema-registry
301+
- title_en: Smart Data Hub
302+
title_cn: 数据智能中心
303+
path: data-integration/smart-data-hub
304304
collapsed: true
305305
children:
306-
- data-integration/schema-registry-example-avro
307-
- data-integration/schema-registry-example-protobuf
308-
- title_en: Schema Validation
309-
title_cn: Schema 验证
310-
path: data-integration/schema-validation
311-
- title_en: Message Transformation
312-
title_cn: 消息转换
313-
path: data-integration/message-transformation
314-
- title_en: Sparkplug
315-
title_cn: Sparkplug
316-
path: data-integration/sparkplug
306+
- title_en: Schema Registry
307+
title_cn: Schema Registry
308+
path: data-integration/schema-registry
309+
collapsed: true
310+
children:
311+
- data-integration/schema-registry-example-avro
312+
- data-integration/schema-registry-example-protobuf
313+
- data-integration/schema-registry-example-external-http
314+
- data-integration/sparkplug
315+
- data-integration/schema-validation
316+
- data-integration/message-transformation
317317

318318
- title_en: Flow Designer
319319
title_cn: Flow 设计器
@@ -526,6 +526,7 @@
526526
path: dashboard/bridgeoverview
527527
children:
528528
- dashboard/rules
529+
- dashboard/data-hub
529530
- title_en: Management
530531
title_cn: 管理
531532
path: dashboard/configuration

en_US/dashboard/bridgeoverview.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,3 @@ The Integration section on the Dashboard provides functions for creating rules,
99
- **Schema Validation**: Use validation rule to ensure that data to be published to specific topics must conform to predefined data formats. For how to create validation rules, see [Configure Schema Validation in Dashboard](../data-integration/schema-validation.md#configure-schema-validation-in-dashboard).
1010
- **Schema**: You can create a schema to be used in the schema validation or SQL rules. For how to create a schema on Dashboard, see [Schema Registry Example - Avro](../data-integration/schema-registry-example-avro.md) or [Schema Registry Example - Protobuf](../data-integration/schema-registry-example-protobuf.md).
1111
- **Message Transform**: Define transformation expressions to adapt data as it flows through the system. For how to create transformations, see [Configure Message Transformation in Dashboard](../data-integration/message-transformation.md#configure-message-transformation-in-dashboard).
12-
13-
14-

en_US/dashboard/data-hub.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Smart Data Hub
2+
3+
The Smart Data Hub section on the Dashboard allows you to create and configure the schema, schema validation rules, and message transformation rules.
4+
5+
- **Schema Registry**: You can create an internal or external schema to be used in the schema validation or SQL rules. For how to create a schema on Dashboard, see [Schema Registry Example - Avro](../data-integration/schema-registry-example-avro.md) or [Schema Registry Example - Protobuf](../data-integration/schema-registry-example-protobuf.md).
6+
- **Schema Validation**: Use validation rule to ensure that data to be published to specific topics must conform to predefined data formats. For how to create validation rules, see [Configure Schema Validation in Dashboard](../data-integration/schema-validation.md#configure-schema-validation-in-dashboard).
7+
- **Message Transform**: Define transformation expressions to adapt data as it flows through the system. For how to create transformations, see [Configure Message Transformation in Dashboard](../data-integration/message-transformation.md#configure-message-transformation-in-dashboard).
8+
480 KB
Loading

en_US/data-integration/message-transformation.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ This section demonstrates how to configure the message transformation feature an
3030

3131
This section demonstrates how to create and configure a message transformation in the Dashboard.
3232

33-
1. Go to Dashboard, and click **Integrations** -> **Message Transform** in the left navigation menu.
33+
1. Go to Dashboard, and click **Smart Data Hub** -> **Message Transform** in the left navigation menu.
3434
2. Click **Create** at the top right of the **Message Transform** page.
3535
3. On the Create Message Transform page, configure the following information:
3636
- **Name**: Enter the name of the transformation.
Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
# Schema Registry Example - External HTTP Server
2+
3+
This page demonstrates how the Schema Registry and Rule Engine support message encoding and decoding using an external HTTP server with custom logic.
4+
5+
In some scenarios, you might need to apply custom encoding or decoding logic that EMQX does not support natively. EMQX allows you to delegate this processing to an external HTTP service by invoking it through `schema_encode` and `schema_decode` functions within a rule.
6+
7+
## External HTTP API Specification
8+
9+
To implement a custom External HTTP API that integrates with EMQX's `schema_encode` and `schema_decode` functions, your External HTTP server must provide a single `POST` endpoint that handles the encoding or decoding requests from EMQX.
10+
11+
### Request Format
12+
13+
The request body is a JSON object with the following fields:
14+
15+
- `payload`: Base64-encoded string value passed to the `schema_encode` or `schema_decode` function in Rule Engine.
16+
- `type`: Either the `encode` or the `decode` string, depending on which function is evaluated, `schema_encode` or `schema_decode`.
17+
- `schema_name`: A string identifying the name of this External HTTP schema configured in EMQX.
18+
- `opts`: An arbitrary string that can be configured in EMQX to provide further options, which is passed unaltered to the HTTP server.
19+
20+
### Response Format
21+
22+
- The server must respond with HTTP status code `200`.
23+
- The response body must contain a base64-encoded string representing the result. Note that this base64 value must not be further JSON-encoded when replying to EMQX.
24+
25+
## Example Use Case
26+
27+
Suppose a device publishes a binary message, and you want to encode or decode the payload using a custom XOR operation. This section demonstrates how to integrate custom encoding and decoding logic into EMQX by building a simple external HTTP service.
28+
29+
### Build an External HTTP Service
30+
31+
The following example demonstrates how to create and run a simple HTTP server using Python and Flask. The server receives Base64-encoded data and applies an XOR operation to the decoded payload.
32+
33+
<details>
34+
<summary><strong>Code for sample External HTTP Server</strong></summary>
35+
36+
Ensure [Flask](https://flask.palletsprojects.com/en/stable/) is installed:
37+
38+
```sh
39+
pip install Flask==3.1.0
40+
```
41+
42+
Sample code:
43+
44+
```python
45+
from flask import Flask, request
46+
import base64
47+
48+
app = Flask(__name__)
49+
50+
@app.route("/serde", methods=['POST'])
51+
def serde():
52+
# The input payload is base64 encoded
53+
body = request.get_json(force=True)
54+
print("incoming request:", body)
55+
payload64 = body.get("payload")
56+
payload = base64.b64decode(payload64)
57+
secret = 122
58+
response = bytes(b ^ secret for b in payload)
59+
# The response must also be base64 encoded
60+
response64 = base64.b64encode(response)
61+
return response64
62+
```
63+
64+
To run your server:
65+
66+
```sh
67+
# This assumes your server is in the same directory in a file named `myapp.py`
68+
flask --app myapp --debug run -h 0.0.0.0 -p 9500
69+
```
70+
71+
</details>
72+
73+
### Create External HTTP Schema in EMQX
74+
75+
1. Go to the Dashboard, and select **Smart Data Hub** -> **Schema Registry** from the left navigation menu.
76+
77+
2. In the **Internal** tab page, click **Create**.
78+
79+
3. Create an External HTTP server schema using the following parameters:
80+
- **Name**: `myhttp`
81+
82+
- **Type**: `External HTTP`
83+
84+
- **URL**: The full URI where your server is running. For example: `http://server:9500/serde`.
85+
86+
4. Click **Create**.
87+
88+
### Create a Rule to Apply Schema
89+
90+
Use the EMQX rule engine to create a rule that applies your schema for message encoding and decoding.
91+
92+
1. In the Dashboard, select **Integration** -> **Rules** from the navigation menu.
93+
94+
2. On the **Rules** page, click **Create** at the top right corner.
95+
96+
3. Use the schema you have just created to write the rule SQL statement:
97+
98+
```sql
99+
SELECT
100+
schema_encode('myhttp', payload) as encoded,
101+
schema_decode('myhttp', encoded) as decoded
102+
FROM
103+
"t/external_http"
104+
```
105+
106+
Both `schema_encode('myhttp', payload)` and `schema_decode('myhttp', encoded)` will call the configured External HTTP server to encode/decode the given payload.
107+
108+
4. Click **Add Action**. Select `Republish` from the drop-down list of the **Action** field.
109+
110+
5. In the **Topic** field, type `external_http/out` as the destination topic.
111+
112+
6. In the **Payload** field, type message content template: `${.}`.
113+
114+
7. Click **Add** to add the action to the rule.
115+
116+
This action sends the decoded message to the topic `external_http/out` in JSON format. `${.}` is a variable placeholder that will be replaced at runtime with the value of the whole output of the rule.
117+
118+
8. Click **Save** to complete the rule creation.
119+
120+
### Check Rule Execution Results
121+
122+
1. In the Dashboard, select **Diagnose** -> **WebSocket Client**.
123+
2. Fill in the connection information for the current EMQX instance.
124+
- If you run EMQX locally, you can use the default value.
125+
- If you have changed EMQX's default configuration. For example, the configuration change on authentication can require you to type in a username and password.
126+
3. Click **Connect** to connect to the EMQX instance as an MQTT client.
127+
4. In the **Subscription** area, type `external_http/out` in the **Topic** field and click **Subscribe**.
128+
129+
5. In the **Publish** area, type `t/external_http` in the **Topic** field, write any payload you wish, and click **Publish**.
130+
131+
6. Check that a message with the topic `external_http/out` is received on the Websocket side. For example, if your payload was `hello`:
132+
133+
```json
134+
{"encoded":"\u0012\u001F\u0016\u0016\u0015","decoded":"hello"}
135+
```

en_US/data-integration/schema-registry.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,14 @@ EMQX Schema Registry currently supports codecs in the below formats:
1010
- [Avro](https://avro.apache.org)
1111
- [Protobuf](https://developers.google.com/protocol-buffers/)
1212
- [JSON Schema](https://json-schema.org/)
13+
- External HTTP server
1314

1415
Avro and Protobuf are Schema-dependent data formats. The encoded data is binary and the decoded data is in [Map format](#rule-engine-internal-data-format-map). The decoded data can be used directly by the rule engine and other plugins. Schema Registry maintains Schema text for built-in encoding formats such as Avro and Protobuf.
1516

1617
JSON schema can be used to validate if the input JSON object is following the schema definitions or if the JSON object output from the rule engine is valid before producing the data to downstream.
1718

19+
External HTTP Server makes all decoding and encoding of payloads go through a configured black-box server that handles the logic. It's useful for cases where one wishes to have custom encoding/decoding logic.
20+
1821
The diagram below shows an example of a Schema Registry application. Multiple devices report data in different formats, which are decoded by Schema Registry into a uniform internal format and then forwarded to the backend application.
1922

2023
<img src="./assets/schema-registry.png" alt="schema-registry" style="zoom:67%;" />
@@ -108,7 +111,7 @@ Starting with version 5.8.1, EMQX supports configuring an external Confluent Sch
108111
109112
You can configure an external schema registry directly through the EMQX Dashboard, making it easy to manage your schema integration.
110113
111-
Go to **Integration** -> **Schema Registry** on EMQX Dashboard. Select the **External** tab on the Schema page.
114+
Go to **Smart Data Hub** -> **Schema Registry** on EMQX Dashboard. Select the **External** tab on the Schema page.
112115
113116
Click the **Create** button at the upper right corner. Configure the following fields:
114117
@@ -200,7 +203,7 @@ select
200203
from 't'
201204
```
202205
203-
##### `schema_encode_and_tag`
206+
##### `schema_encode_and_tag`
204207
205208
This function uses a locally registered Avro schema, an external CSR schema name, and a subject to encode a payload (already in internal map format), and to tag the resulting payload with a schema ID. The schema ID comes from registering the local schema to CSR.
206209
@@ -217,7 +220,7 @@ select
217220
from 't'
218221
```
219222
220-
##### `schema_decode_tagged`
223+
##### `schema_decode_tagged`
221224
222225
This function uses a CSR name to decode a payload, assuming it is tagged with the schema ID retrieved from CSR.
223226
@@ -229,4 +232,3 @@ select
229232
) as decoded
230233
from 't'
231234
```
232-

en_US/data-integration/schema-validation.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ This section demonstrates how to configure the schema validation feature and how
4646

4747
This section demonstrates how to create and configure a schema validator in the Dashboard.
4848

49-
1. Click on **Integrations** -> **Schema Validation** in the left navigation of the Dashboard.
49+
1. Click on **Smart Data Hub** -> **Schema Validation** in the left navigation of the Dashboard.
5050
2. Click **Create** at the top right of the **Schema Validation** page.
5151
3. On the Create Schema Validation page, configure the following settings:
5252
- **Name**: Enter the name of the validator.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Smart Data Hub
2+
3+
The Smart Data Hub of EMQX is an all-in-one solution for intelligent data processing. It is designed to simplify and efficiently manage MQTT data streams. With the Smart Data Hub, you can easily manage schemas, validate data, and perform real-time data transformations as needed. Whether for data validation or message transformation, this platform enables automated and efficient data management.
4+
5+
## Key Features
6+
7+
The Smart Data Hub provides the following key features:
8+
9+
- **[Schema Registry](./schema-registry.md)**: Create, modify, and delete data schemas to ensure consistency in data formats and standards.
10+
- **[Schema Validation](./schema-validation.md)**: Validate incoming data against predefined schemas to prevent formatting errors and data inconsistencies.
11+
- **[Message Transformation](./message-transformation.md)**: Transform data messages in real-time, formatting or mapping MQTT data as needed to suit various application scenarios.
12+
13+
![data_hub](./assets/data_hub.png)

zh_CN/dashboard/data-hub.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# 数据智能中心
2+
3+
您可以通过 Dashboard 中的数据智能中心模块创建和配置 Schema、Schema 验证规则以及消息转换规则。
4+
5+
- **Schema Registry**: 您可以在本页创建一个内部或外部的 Schema 用于模式验证或 SQL 规则。有关如何创建模式,请参考[编解码举例 - Avro](../data-integration/schema-registry-example-avro.md) or [编解码举例 - Protobuf](../data-integration/schema-registry-example-protobuf.md)
6+
- **Schema 验证**:您使用验证规则来确保发布到特定主题的数据必须符合预定义的数据格式。有关如何创建验证规则,请参考[在 Dashboard 中配置 Schema 验证](../data-integration/schema-validation.md#在-dashboard-中配置-schema-验证)
7+
- **消息转换**:通过定义消息转换表达式,在数据流经系统时对其进行适配。有关如何创建消息转换的详细信息,请参阅[在 Dashboard 中配置消息转换](../data-integration/message-transformation.md#在-dashboard-中配置消息转换)
8+
480 KB
Loading

zh_CN/data-integration/message-transformation.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030

3131
本节演示如何在 Dashboard 中创建和配置消息转换。
3232

33-
1. 进入 Dashboard,点击左侧导航菜单中的**集成** -> **消息转换**
33+
1. 进入 Dashboard,点击左侧导航菜单中的**数据智能中心** -> **消息转换**
3434
2.**消息转换**页面右上角点击**创建**
3535
3. 在创建消息转换页面,配置以下信息:
3636
- **名称**:输入转换的名称。
@@ -90,7 +90,7 @@ message_transformation {
9090

9191
### 创建解码/编码模式
9292

93-
有关如何创建解码和编码模式的更多信息,请参阅 [Schema Registry](./schema-registry.md)部分。
93+
有关如何创建解码和编码模式的更多信息,请参阅 [Schema Registry](./schema-registry.md) 部分。
9494

9595
## 统计与指标
9696

0 commit comments

Comments
 (0)