You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/UserGuide/Master/Table/API/Programming-MQTT.md
+49-35Lines changed: 49 additions & 35 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -22,20 +22,27 @@
22
22
23
23
## 1. Overview
24
24
25
-
[MQTT](Message Queuing Telemetry Transport)(http://mqtt.org/) is a lightweight messaging protocol designed for IoT and low-bandwidth environments. It operates on a Publish/Subscribe (Pub/Sub) model, enabling efficient and reliable bidirectional communication between devices. Its core objectives are low power consumption, minimal bandwidth usage, and high real-time performance, making it ideal for unstable networks or resource-constrained scenarios (e.g., sensors, mobile devices).
25
+
MQTT(Message Queuing Telemetry Transport) is a lightweight messaging protocol designed for IoT and low-bandwidth environments. It operates on a Publish/Subscribe (Pub/Sub) model, enabling efficient and reliable bidirectional communication between devices. Its core objectives are low power consumption, minimal bandwidth usage, and high real-time performance, making it ideal for unstable networks or resource-constrained scenarios (e.g., sensors, mobile devices).
26
26
27
27
IoTDB provides deep integration with the MQTT protocol, fully compliant with MQTT v3.1 (OASIS International Standard). The IoTDB server includes a built-in high-performance MQTT Broker module, eliminating the need for third-party middleware. Devices can directly write time-series data into the IoTDB storage engine via MQTT messages.
The Built-in MQTT Service provide the ability of direct connection to IoTDB through MQTT. It listen the publish messages from MQTT clients
35
-
and then write the data into storage immediately.
36
-
The MQTT topic corresponds to IoTDB timeseries.The first segment of the MQTT topic (split by `/`) is used as the database name.The table name is derived from the `<measurement>` in the line protocol.
37
-
The messages payload can be format to events by `PayloadFormatter` which loaded by java SPI, and the implementation of `PayloadFormatter` for table is `LinePayloadFormatter`.
38
-
The following is the line protocol syntax of MQTT message payload and an example:
34
+
By default, the IoTDB MQTT service loads configurations from `${IOTDB_HOME}/${IOTDB_CONF}/iotdb-system.properties`.
[MQTT](Message Queuing Telemetry Transport)(http://mqtt.org/) is a lightweight messaging protocol designed for IoT and low-bandwidth environments. It operates on a Publish/Subscribe (Pub/Sub) model, enabling efficient and reliable bidirectional communication between devices. Its core objectives are low power consumption, minimal bandwidth usage, and high real-time performance, making it ideal for unstable networks or resource-constrained scenarios (e.g., sensors, mobile devices).
25
+
MQTT(Message Queuing Telemetry Transport) is a lightweight messaging protocol designed for IoT and low-bandwidth environments. It operates on a Publish/Subscribe (Pub/Sub) model, enabling efficient and reliable bidirectional communication between devices. Its core objectives are low power consumption, minimal bandwidth usage, and high real-time performance, making it ideal for unstable networks or resource-constrained scenarios (e.g., sensors, mobile devices).
26
26
27
27
IoTDB provides deep integration with the MQTT protocol, fully compliant with MQTT v3.1 (OASIS International Standard). The IoTDB server includes a built-in high-performance MQTT Broker module, eliminating the need for third-party middleware. Devices can directly write time-series data into the IoTDB storage engine via MQTT messages.
|`mqtt_max_message_size`| Maximum allowed MQTT message size (bytes). | 1048576 |
74
73
75
74
## 4. Coding Examples
76
75
The following is an example which a mqtt client send messages to IoTDB server.
@@ -102,10 +101,41 @@ connection.disconnect();
102
101
103
102
## 5. Customize your MQTT Message Format
104
103
105
-
If you do not like the above Json format, you can customize your MQTT Message format by just writing several lines
106
-
of codes. An example can be found in [example/mqtt-customize](https://github.com/apache/iotdb/tree/master/example/mqtt-customize) project.
104
+
In a production environment, each device typically has its own MQTT client, and the message formats of these clients have been pre-defined. If communication is to be carried out in accordance with the MQTT message format supported by IoTDB, a comprehensive upgrade and transformation of all existing clients would be required, which would undoubtedly incur significant costs. However, we can easily achieve customization of the MQTT message format through simple programming means, without the need to modify the clients.
105
+
An example can be found in [example/mqtt-customize](https://github.com/apache/iotdb/tree/rc/2.0.1/example/mqtt-customize) project.
106
+
107
+
Assuming the MQTT client sends the following message format:
108
+
```json
109
+
{
110
+
"time":1586076045523,
111
+
"deviceID":"car_1",
112
+
"deviceType":"Gasoline car",
113
+
"point":"Fuel level",
114
+
"value":10.0
115
+
}
116
+
```
117
+
Or in the form of an array of JSON:
118
+
```java
119
+
[
120
+
{
121
+
"time":1586076045523,
122
+
"deviceID":"car_1",
123
+
"deviceType":"Gasoline car",
124
+
"point":"Fuel level",
125
+
"value":10.0
126
+
},
127
+
{
128
+
"time":1586076045524,
129
+
"deviceID":"car_2",
130
+
"deviceType":"NEV(new enegry vehicle)",
131
+
"point":"Speed",
132
+
"value":80.0
133
+
}
134
+
]
135
+
```
136
+
137
+
Then you can set up the custom MQTT message format through the following steps:
0 commit comments