Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Source: MQTT v5

The MQTT source subscribes to MQTT topics and delivers messages into a pg_tide inbox. This is ideal for ingesting IoT telemetry, sensor data, and device events into PostgreSQL for processing and analytics.

Configuration

SELECT tide.relay_set_inbox(
    'telemetry-from-devices',
    'device_telemetry',
    '{
        "source_type": "mqtt",
        "url": "mqtts://${env:MQTT_BROKER}:8883",
        "topic": "devices/+/telemetry",
        "qos": 1,
        "client_id": "pg-tide-ingest-01",
        "username": "${env:MQTT_USER}",
        "password": "${env:MQTT_PASS}",
        "tls_enabled": true
    }'::jsonb
);

Configuration Reference

ParameterTypeDefaultDescription
source_typestringMust be "mqtt"
urlstringMQTT broker URL
topicstringMQTT topic filter (supports + and # wildcards)
qosint1Quality of Service level
client_idstringautoMQTT client ID
usernamestringnullAuth username
passwordstringnullAuth password
tls_enabledboolfalseEnable TLS
clean_startboolfalseClean session on connect

Delivery Guarantees

With QoS 1, the MQTT broker guarantees at-least-once delivery to the relay. The inbox's deduplication handles any duplicates that arrive. With clean_start: false, the broker retains subscriptions and queues messages while the relay is offline.

Further Reading