MQTT
Allows publishing events through MQTT, ideal for IoT and lightweight streaming
Overview
MQTT is a lightweight, publish-subscribe protocol ideal for machine-to-machine communication in IoT environments.
Joule leverages MQTT to publish events through an MQTT publisher, allowing communication between devices and services over specified topics.
Client library: org.eclipse.paho:org.eclipse.paho.mqttv5.client:1.2.5
Examples & DSL attributes
This example configures an MQTT publisher to send events to the mydevice/leaf
topic.
The events are published as compressed JSON, using QoS level 1 for reliable delivery.
The publisher connects with the client ID myClientId
, username lyndon
and tenant uk
to the broker at tcp://127.0.0.1:1883
. Security is handled with a JWT claim using RSA encryption, with a private key stored in file2
.
Attributes schema
Serialisation attributes schema
Serialiser example
In this example, the MQTT publisher is configured to serialise StreamEvents
as compressed JSON payloads.
The compress
setting is enabled to reduce the size of the data and batch
is set to false
, meaning events are sent individually rather than in batches.
Last will attributes schema
These attributes provide the configuration parameters to send publisher disconnection notifications to connected subscribers.
Last will example
In this example, the last will
feature is configured for the MQTT publisher.
It specifies that if the publisher disconnects unexpectedly, a message will be sent to the topic usecasename/status/failure
to notify subscribers of the disconnection.
The message will indicate that the Joule MQTT process disconnected from broker
and the publisher will wait for a delay of 15 seconds before sending this notification.
Additional resources
Official Mosquitto documentation
Good user documentation
MQTT X UI for testing
Last updated