← Back to the chapter · Previous detail

Technical detail · MQTT Architecture

Broker state and PUBLISH evidence

Routing is only part of the broker’s job, so I’ll separate the state it can hold. Session state is the broker’s record for a client, including subscriptions and eligible queued messages. Whether it survives disconnection depends on the session rules and broker settings. A retained message is the latest value stored for a topic and delivered to new matching subscribers. It is useful for a state snapshot and risky for a one-time command. A late listener receiving a snapshot is different from a returning client receiving queued work.

A last will is a preconfigured message the broker can publish when a client disconnects unexpectedly. It signals a loss of contact; it is not a complete fault diagnosis. For a house with a sensor and a controlled valve, distinguish the sensor’s reported state from evidence about its connection. Neither replaces an application report of what the valve actually did.

A stored last-will notice and a device’s reported condition provide different evidence. The workbench opens separately so you can examine when the broker publishes or cancels a will.

Simulation · interactive

MQTT Last Will Workbench

Trace when the broker publishes a stored will and when it cancels it.

The boiler example in Figure 2.5 applies wildcard matching to the house’s topics. plant/boiler7/temperature matches plant/+/temperature. The command topic plant/boiler7/valve/set does not match that temperature filter. Follow each route to the application boundary: a protocol acknowledgement cannot establish that the valve acted.

The boiler packet view in Figure 2.7 and Figure 2.8 makes the packet boundary visible. It uses plant/boiler7/temperature and an 83.4 C payload, matching the earlier boiler example. The fixed header carries publication flags, remaining length frames the packet body, and the topic selects the route. The packet identifier tracks QoS 1 or 2 exchange state. It is not the application’s identity for a command. A routed payload still needs its meaning and format checked by the receiving application.

← Back to the chapter · Previous detail