MQTT Publish-Subscribe: Reference
More
Depth: Practitioner
Progress saves as you read. Mark sections complete as you go; your progress appears in the sidebar.
I’m Bex. These reference excerpts support MQTT Publish-Subscribe Basics. Return there to follow the boiler-sensor house. The old check headings in the preserved excerpts refer to the standalone knowledge check.
Route model and simulation
I’ll start with the route model behind the chapter’s matching example.
A topic filter asks which messages a client wants. An access-control list, or ACL, says which topics that identity may read or write. A match and a permission answer different questions. Keep both in the route record.
For the boiler prediction, assume the subscriptions have been accepted, both listeners are connected and authorized, and transfer succeeds. The operations screen asks for plant/+/temperature. The alarm service asks for plant/#. Read plus as “one level” and hash as “the rest of this branch”. Hash must be the final filter level.
Copy the concrete publication beside each filter. Compare literal levels first, then let each wildcard consume only its allowed levels. Predict the matching set. To test the prediction, request the broker’s forwarding trace and a subscriber receipt with the topic and payload. Broker acceptance alone stops too early.

Simulation · interactive
Publish/Subscribe Flow Workbench
Explore how the system behaves.
The MQTT Roles
Publisher
Sends the boiler reading to plant/boiler7/temperature. It names the route, not each receiving application.
Broker
Compares that name with stored filters and forwards permitted matches. Authentication and topic permissions need explicit configuration.
Subscriber
Requests a filter such as plant/+/temperature. It checks the content and age of the readings it receives.
Beginner Examples
Worked example. The input is plant/boiler7/temperature with payload 83.4 C, or 83.4 degrees Celsius. For the operations filter, plant agrees, plus consumes boiler7, and temperature agrees: match. For the alarm filter, plant agrees and hash consumes the remaining branch: match. The exact filter plant/boiler7/pressure fails at the last level: no match. Under our delivery assumptions, the operations screen and alarm service receive the reading. The pressure monitor does not.
Overview Knowledge Check
For the next reading, compare the topic with each filter, check permission, then check receipt. Adding a listener changes the broker’s subscriptions, not the boiler sensor’s destination list.
Topic record and design workflow
With that route in mind, I’ll keep the original design record here for a closer review.
Quality of service, shortened to QoS, is the MQTT delivery level. A retained message is a last-known snapshot stored for a topic. A session holds client-related state such as subscriptions and eligible queued messages. A configured last will lets the broker publish status after an unexpected connection loss. A duplicate repeats a message; a stale value is too old for its intended use. These choices belong in the record because matching alone does not settle them.
Topic Record Workflow
+ or # wildcard use, including who owns each broad subscription.
Worked Example: Greenhouse Telemetry
The greenhouse sensor publishes to site/greenhouse-2/sensor-17/air/temperature. Compare it with site/greenhouse-2/+/air/temperature. Site and greenhouse agree; plus takes the sensor level; air and temperature agree. The dashboard can cover other sensors at the same greenhouse without receiving other signal types. The alarm rule and history archive still need their own subscription and application requirements.
site/greenhouse-2/sensor-17/air/temperaturesite/greenhouse-2/+/air/temperaturesite/greenhouse-2/#Correct topic, delivery, and freshness mistakes.
- Topic: Do not use
site/#for a dashboard that needs only greenhouse 2 temperature readings. Publish tosite/greenhouse-2/sensor-17/air/temperature, whose path names site, device, capability, and signal; subscribe withsite/greenhouse-2/+/air/temperatureto cover its matching sensors without other sites or signal types. - QoS: Do not treat a matching topic as a delivery-state record. Record QoS, retained use, session behavior, and last will separately so the delivery assumptions can be reviewed.
- Subscriber: Do not display retained or delayed values as live without checking their age. Keep the broad
#filter for operations alone, and mark old values as stale in the dashboard.
This record avoids two common mistakes: making the topic too vague for authorization, and using wildcards so broadly that subscribers receive data they do not need or should not see.
Practitioner Knowledge Check
Apply the same rule to the humidity recheck: hold greenhouse 4 and humidity fixed, then allow the sensor level to vary. A smaller filter does not replace an ACL; it makes the intended audience easier to state and test.
Broker boundaries and delivery reference
From the topic record, I’ll turn to the evidence kept at each broker boundary.
Separate authentication, which checks identity, from authorization, which checks permission. A staff display may be allowed to read room temperatures while command topics remain denied. Keep evidence of the allowed path and the denied path.
Broker Boundary Ledger
Mechanics That Matter
Topic filters select routes. Plus matches one level. A final hash includes the remaining branch. Neither checks payload meaning. QoS controls delivery. Quality of service is the MQTT delivery level. QoS zero has no protocol acknowledgement; higher levels still do not prove application action. Applications still need freshness and duplicate handling. An idempotent operation keeps the same intended state when repeated. Retained state belongs to a topic. A new matching subscription can receive its last-known snapshot. Session state belongs to a client. Its settings and broker limits decide which eligible messages can wait while that client is offline. A retained snapshot and an offline queue answer different questions.
Topic board
- Topic: Do not use the payload value to decide routing. Compare the concrete topic name with the filter before inspecting the value.
- QoS: Do not extend a delivery confirmation to a physical result. Ask what this delivery leg confirms.
- Subscriber: Do not assume that a late value is fresh. Check whether it came from retained topic state or a client queue, then check its age.
Common Review Pitfalls
Using hash for every application admits unrelated branches. Narrow the filter and enforce its permissions at the broker. Checking authorization only in the screen lets unwanted data reach that client before it hides it. Deny the route at the broker. Treating retained as fresh makes an old snapshot look live. Show its timestamp or age. Treating silence as health hides missing devices. Configure status, a Will, and a stale-data rule; a Will reports an unexpected connection loss, not a temperature or a complete fault diagnosis.
Under-the-Hood Knowledge Check
Keep the first missing piece of evidence in the record. A failed match calls for a topic or filter correction. An authorization failure calls for a permission review. A received but stale reading calls for the application’s freshness rule. Increasing QoS cannot repair all three.
Detail notes moved from the chapter

Technical detail
One route, two listeners
Name the sender, routing service, and receiving applications.

Technical detail
Command and physical result
Keep receipt evidence beside reported state.
