MQTT is a publish/subscribe protocol that allows clients to listen to a stream of events produced to a server.
It is widely used in real-time and IoT applications since it is lightweight and easy to use.
The inbound MQTT connector supports the following configuration options:
The hostname of the MQTT server to subscribe to
This value can be provided as a parameter or as a secret
The topic filter to use when receiving MQTT events
version: 0.5.2 name: my-mqtt type: mqtt-source topic: mqtt-topic parameters: mqtt_topic: "/hfp/v2/journey/#" secrets: MQTT_URL: mqtts://mqtt.hsl.fi:8883/
There are two important pieces of information that we’re interested in capturing from every MQTT event.
In MQTT, topics are more of a label for particular message types. When we specify a
mqtt-topic to subscribe to, we are actually defining a “filter”, or a pattern that
tells MQTT which events we are interested in receiving.
This means that events we receive may not all belong to the same topic - rather, they all match the filter we provided.
The result of the event message body produced to Fluvio by the inbound MQTT connector is a JSON object containing:
Furthermore, since MQTT allows events to contain arbitrary binary data, the payload is encoded as a byte buffer.
Below is a sample of what an MQTT event captured and sent to Fluvio looks like: