← Back to the chapter · Next detail →
Technical detail · MQTT Architecture
MQTT control packets and topic routing
Message Queuing Telemetry Transport (MQTT) uses control packets and stored state to route messages when clients leave or return. A packet is a unit of network data; a broker routes messages from publishing clients to subscribing clients whose topic filters match. A topic is a message’s routing name, a filter selects topic names, and a payload is the carried application data. Quality of service (QoS) is the chosen protocol delivery level.
Follow the methods in lifecycle order in Figure 2.1. CONNECT starts the connection and CONNACK reports its result. SUBSCRIBE requests filters and SUBACK reports the subscription result. PUBLISH carries a named message, with replies according to the delivery level. UNSUBSCRIBE removes a filter, and DISCONNECT closes the link on purpose.
The wildcard matrix in Figure 2.4 shows how those subscriptions select traffic. A wildcard lets a filter match varying topic levels. Each slash separates a level. + matches exactly one level; # matches the remaining levels and must be the final level in a filter. Publishers always send concrete names. A wildcard belongs in the subscription filter.