Integrate HiveMQ with Tiger Cloud
Connect HiveMQ to Tiger Cloud and stream MQTT messages into a hypertable
HiveMQ is an enterprise MQTT broker used to move data between IoT devices, applications, and backend systems in real time.
This page shows you how to connect HiveMQ to your Tiger Cloud service using the HiveMQ Enterprise Extension for PostgreSQL to stream MQTT messages into Tiger Cloud.
Prerequisites for this integration guide
To follow these steps, you'll need:
-
These steps use Tiger Cloud, but the same approach applies to a self-hosted TimescaleDB instance.
- Your connection details.
- A HiveMQ Enterprise broker with file system access on the host
- The HiveMQ Enterprise Extension for PostgreSQL downloaded
Create a target table in Tiger Cloud
Section titled “Create a target table in Tiger Cloud”- Connect to your service
Use the Tiger Console,
psql, or any other SQL editor to connect to your Tiger Cloud service. - Create a hypertable for MQTT messages
Create a
hypertablefor time-series readings. The table stores the event time, atag_id, the numericvalue, and payload metadata fields:CREATE TABLE mqtt_messages (ts TIMESTAMPTZ NOT NULL,tag_id TEXT NOT NULL,value DOUBLE PRECISION,quality TEXT,units TEXT) WITH (tsdb.hypertable = true,tsdb.chunk_interval = '1 day');
Install and configure the HiveMQ Enterprise Extension for PostgreSQL
Section titled “Install and configure the HiveMQ Enterprise Extension for PostgreSQL”- Install the extension
Unpack the extension into the
extensionsdirectory of your HiveMQ installation:Terminal window unzip hivemq-postgresql-extension-<version>.zip -d <HIVEMQ_HOME>/extensions/The extension folder is disabled by default. Remove the
DISABLEDmarker file once you have finished configuring it in the next steps:Terminal window rm <HIVEMQ_HOME>/extensions/hivemq-postgresql-extension/DISABLED - Configure the database connection
Edit
<HIVEMQ_HOME>/extensions/hivemq-postgresql-extension/conf/config.xmland add a PostgreSQL connection that points to your Tiger Cloud service. Use the username, password, host, and port from your service connection details:<hivemq-postgresql-extension><postgresqls><postgresql><id>tiger-cloud</id><host>YOUR_SERVICE_HOST.tsdb.cloud.timescale.com</host><port>5432</port><database>tsdb</database><username>tsdbadmin</username><password>YOUR_PASSWORD</password><tls><enabled>true</enabled></tls></postgresql></postgresqls></hivemq-postgresql-extension> - Define a route from MQTT topics to your table
Still in
config.xml, add an MQTT-to-PostgreSQL route that uses a statement template to parse JSON payload fields and insert them into separate columns onmqtt_messages:<mqtt-to-postgresql-routes><mqtt-to-postgresql-route><id>mqtt-to-tiger-cloud</id><postgresql-id>tiger-cloud</postgresql-id><mqtt-topic-filters><mqtt-topic-filter>uns/tiger-data/#</mqtt-topic-filter></mqtt-topic-filters><processor><statement-template>conf/examples/hivemq-mqtt-message-template.sql</statement-template></processor></mqtt-to-postgresql-route></mqtt-to-postgresql-routes>Narrow the
<mqtt-topic-filter>to the topics you want to persist. Use#only if you want to capture every message on the broker. - Create the statement template file
Create the statement template file at
HIVEMQ_HOME/extensions/hivemq-postgresql-extension/conf/examples/hivemq-mqtt-message-template.sql. This will need to be customized based on the message format.Sample MQTT topic and JSON
Section titled “Sample MQTT topic and JSON”Given an mqtt topic and JSON as follows:
uns/tiger-data/plant-7/sensor-123/reading{"timestamp": "2026-06-12T14:26:00Z","value": 74.5,"quality": "GOOD","units": "°F"}Then the template file might look like this:
INSERT INTO mqtt_messages (ts, tag_id, value, quality, units)VALUES (((${mqtt-payload-utf8})::jsonb ->> 'timestamp')::timestamptz,${mqtt-topic},((${mqtt-payload-utf8})::jsonb ->> 'value')::double precision,((${mqtt-payload-utf8})::jsonb ->> 'quality'),((${mqtt-payload-utf8})::jsonb ->> 'units'));The
timestampfield must be valid ISO 8601 so the cast totimestamptzsucceeds.See the HiveMQ extension reference for the full list of placeholders and supported statement templates. In this example, the topic was used as the tag_id.
- Start HiveMQ and verify the extension is loaded
Start (or restart) HiveMQ and check the broker log for a line confirming the extension is started and the route is active:
Terminal window tail -f <HIVEMQ_HOME>/log/hivemq.logPublish a test message to a topic that matches your filter, then query the table to confirm rows are arriving:
SELECT * FROM mqtt_messages ORDER BY ts DESC LIMIT 10;
With messages flowing into mqtt_messages, add a retention policy to cap how long historical data is kept. The step below can be performed in the Tiger Console or any other SQL editor.
Optimize for HiveMQ workloads
Section titled “Optimize for HiveMQ workloads”- Optional: add a retention policySELECT add_retention_policy('mqtt_messages', INTERVAL '1 year');
You have successfully integrated HiveMQ with Tiger Cloud.