Skip to content

MQTT v5 Connector

The MQTT v5 connector enables publish/subscribe messaging using the MQTT 5.0 protocol, adding shared subscriptions, user properties, and message expiry on top of MQTT v3.

Connector Types:

  • MqttV5Reader - Subscribe to MQTT 5.0 topics
  • MqttV5Writer - Publish to MQTT 5.0 topics

For MQTT 3.1.1 brokers and clients, use the MQTT v3 connector.

Subscribe to a topic:

{
"type": "MqttV5Reader",
"config": {
"endpoint": "mqtt://localhost:1883",
"topic": "sensors/temperature",
"qos": 1,
"clientId": "meddle-v5-reader"
}
}
{
"type": "MqttV5Reader",
"config": {
"endpoint": "mqtts://mqtt.example.com:8883",
"topic": "factory/sensors/#",
"qos": 1,
"clientId": "meddle-v5-reader",
"username": "mqtt_user",
"password": "mqtt_password"
}
}

Distribute messages across multiple readers using sharedGroup. The connector subscribes to $share/<group>/<topic> and the broker load-balances deliveries between members:

{
"type": "MqttV5Reader",
"config": {
"endpoint": "mqtt://broker.example.com:1883",
"topic": "factory/events",
"qos": 1,
"clientId": "meddle-v5-reader-1",
"sharedGroup": "meddle-workers"
}
}

Publish to a topic:

{
"type": "MqttV5Writer",
"config": {
"endpoint": "mqtt://localhost:1883",
"topic": "data/output",
"qos": 1,
"clientId": "meddle-v5-writer"
}
}

Retained Message with Expiry and User Properties

Section titled “Retained Message with Expiry and User Properties”
{
"type": "MqttV5Writer",
"config": {
"endpoint": "mqtts://mqtt.example.com:8883",
"topic": "devices/state",
"qos": 1,
"clientId": "meddle-v5-writer",
"username": "mqtt_user",
"password": "mqtt_password",
"retain": true,
"messageExpiry": 3600,
"userProperties": {
"source": "meddle",
"schema": "v1"
}
}
}
  • endpoint: Broker URL with scheme (mqtt://host:port or mqtts://host:port)
  • topic: Topic to subscribe or publish to (Reader supports + and # wildcards)
  • qos: Quality of Service: 0, 1, or 2
  • clientId: (Optional) Client identifier
  • username: (Optional) MQTT username
  • password: (Optional) MQTT password
  • sharedGroup: (Reader) Shared subscription group for load balancing
  • userProperties: Key/value metadata attached to messages
  • retain: (Writer) Broker stores the last message and delivers it to new subscribers
  • messageExpiry: (Writer) Message expiry interval in seconds
  • 0: At most once (fire and forget)
  • 1: At least once (acknowledged delivery)
  • 2: Exactly once (assured delivery)
  • Shared subscriptions (sharedGroup) let multiple subscribers consume a single topic with broker-side load balancing.
  • User properties carry arbitrary key/value metadata per message.
  • Message expiry drops undelivered messages after the configured interval.
  • Reason codes on connect, subscribe, and publish provide richer error semantics handled by the underlying paho client.
  • + - Single level wildcard (sensors/+/temperature)
  • # - Multi-level wildcard (sensors/#)
  • MQTT v3 - Classic MQTT 3.1.1 connector
  • AMQP - RabbitMQ pub/sub alternative
  • NATS - Cloud-native pub/sub alternative