Prerequisites
Before ingesting data from MQTT into RisingWave, please ensure the following:- The MQTT server is running and accessible from your RisingWave cluster.
- If authentication is required for the MQTT broker, make sure you have the client username and password. The client user must have the
subscribepermission for the topic. - Create the MQTT topic from which you want to ingest data.
- Ensure that your RisingWave cluster is running.
iot_data with the data from various IoT devices at a given timestamp, including temperature, humidity readings, and a status field indicating whether the device is in a normal or abnormal state. For more information to learn about MQTT and get started with it, refer to the MQTT guide.
Ingest data into RisingWave
When creating a source, we have the option to either persist the data in RisingWave usingCREATE TABLE or use CREATE SOURCE while specifying the connection settings and data format.
Syntax
Parameters
This SQL statement creates a table named
iot_sensor_data with columns for device ID, timestamp, temperature, humidity, and device status. The table is configured to connect to an MQTT broker using the MQTT connector, with specific URL, topic, and quality of service (QoS) settings, the data is encoded as JSON.