MQTT Schema ([mqtt])
When protocol = "mqtt" is set, Rumour acts as an autonomous MQTT client connecting directly to an IoT message broker (e.g., Mosquitto, EMQX, Aedes).
The [mqtt] block configures the pub/sub topics and the Quality of Service guarantees.
Actionable Quickstart
Want to test this schema right now? You can run it against the official rumour-mock-server repository.
1. Start the Mock Server
In a new terminal window, boot up the multi-protocol mock server (provides a Aedes MQTT broker on port 1883):
cd rumour-mock-server/mock-server
npm install
npm start
2. Scaffold a Workspace
In your main terminal, initialize a fresh testing workspace:
mkdir try_mqtt
cd try_mqtt
rumour init
rumour new mqtt_tests
3. Create the Request File
Paste this complete request into mqtt_tests/request.toml. This performs an atomic loopback: subscribing to a topic and publishing a message to ensure it routes successfully.
name = "quickstart_mqtt"
protocol = "mqtt"
[request]
method = "POST"
url = "mqtt://127.0.0.1:1883"
[body]
type = "text"
raw = "Hello from Rumour MQTT!"
[mqtt]
action = "publish_subscribe"
topic = "quickstart/test"
subscribe_topic = "quickstart/test"
qos = 1
timeout_ms = 5000
expect_message = "Rumour"
[assert]
status = 200
4. Run the Test
Execute the test. Rumour will connect to the Aedes broker, lock in the subscription, fire the payload, and listen for the echo!
rumour run mqtt_tests/ -v
Root Parameters
| Field | Type | Required | Description |
|---|---|---|---|
action | String | Yes | The core workflow. Options: publish, subscribe, publish_subscribe. |
topic | String | Depends | The topic to publish the [body] to (Required if action contains publish). |
subscribe_topic | String | Depends | The topic to listen to (Required if action contains subscribe). |
qos | Integer | No | Quality of Service: 0, 1, or 2 (Defaults to 1). |
timeout_ms | Integer | No | The maximum time allowed for the broker to acknowledge or route a message (Defaults to 5000). |
expect_message | String | Depends | The substring to assert against when receiving a message (Required if action contains subscribe). |
Action Workflows
1. publish
A unidirectional blast. Rumour connects to the broker, sends the payload to topic, waits for the QoS acknowledgement (if QoS > 0), and exits.
[mqtt]
action = "publish"
topic = "sensors/temperature"
qos = 0
2. subscribe
A passive listener. Rumour connects to the broker, registers a subscription to subscribe_topic, and blocks until a message arrives or timeout_ms triggers.
[mqtt]
action = "subscribe"
subscribe_topic = "alerts/critical"
expect_message = "CRITICAL_FAILURE"
timeout_ms = 30000
3. publish_subscribe (Loopback/Echo)
The ultimate integration testing action. Rumour orchestrates an atomic operation to prevent race conditions:
- Subscribes to
subscribe_topic. - Blocks until the broker confirms the subscription.
- Publishes the payload to
topic. - Blocks until a message matching
expect_messagearrives on the subscribed channel.
[mqtt]
action = "publish_subscribe"
topic = "devices/activation/request"
subscribe_topic = "devices/activation/response"
qos = 1
expect_message = "ACTIVATED"
timeout_ms = 5000
Quality of Service (QoS)
Rumour rigorously respects MQTT QoS levels during test executions:
qos = 0(At most once): "Fire and forget." Rumour will mark the test as successful the millisecond the payload is written to the TCP socket, regardless of whether the broker processes it.qos = 1(At least once): Rumour will keep the test running until the broker returns aPUBACKpacket.qos = 2(Exactly once): Rumour enforces the full 4-step handshake (PUBREC,PUBREL,PUBCOMP) before marking the node as successful.