Integration & Gateways · Study deck

Pub/Sub and Topic Routing

A greenhouse probe publishes humidity without knowing which dashboard, alarm service, or archive will use it.

Gateway Gus is your guide for this deck.

commbridgepubsub
Gateway Gus, the module guide, in a scene from this chapter.
iotclass.org

After studying this chapter

Learning objectives

You will be able to:

  • design topic names as a stable contract rather than an implementation detail
  • explain why wildcard subscription matching is not the same as authorization
  • distinguish per-hop QoS delivery guarantees from end-to-end exactly-once delivery
  • diagnose retained-message replay traps and dead-letter routing failures
iotclass.org

Major section

Publishers Speak to Topics, Not People

A broker is the service that matches a named message route to interested readers.

  • A gateway is a device or service that joins different networks or data forms.
  • The sensor may know neither the dashboard nor the gateway, so the route and access rules must carry the promise.
  • Practitioner designs names, filters, and records.

Why it matters

That contrast matters because Pub/sub routing is a broker contract: publishers send once, then the broker matches subscriptions and fans out bounded copies to approved consumers.

Pub/sub routing is a broker contract: publishers send once, then the broker matches subscriptions and fans out bounded copies to approved consumers.
Pub/sub routing is a broker contract: publishers send once, then the broker matches subscriptions and fans out bounded copies to approved consumers.
iotclass.org

Major section

Publishers Speak to Topics, Not People (continued)

A match proves routing, not permission or useful action.

  • The shared route can inform many users, but it should not become the only path to an immediate safety step.
  • This opening does not choose a topic tree or delivery level.
  • Relate it to “Broker”, then carry “topic matcher” toward “subscriptions”.
iotclass.org

Major section

Read a Topic as a Public Contract

The publisher sends a routing record to a named topic rather than to a particular application.

  • This separation lets one consumer stop without changing the probe, but it also makes the topic tree an interface that deserves version control.
  • A display subscribes to farm/+/humidity, while an archive subscribes to farm/#.

Why it matters

Unit, quality, observation time, and schema version belong in the payload because subscribers need them to interpret each topic message.

Pub/sub routing is a broker contract: publishers send once, then the broker matches subscriptions and fans out bounded copies to approved consumers.
Pub/sub routing is a broker contract: publishers send once, then the broker matches subscriptions and fans out bounded copies to approved consumers.
iotclass.org

Major section

Read a Topic as a Public Contract (continued)

A sensor publishes {"value":68.4,"unit":"%","observed_at":"10:05:20"}.

  • The single-level + selects humidity from any one greenhouse name at that position.
  • The multi-level # includes all descendant farm topics.
  • A maintenance command must use a separate, access-controlled branch rather than hiding state-changing writes among telemetry.
  • Topic names should carry stable routing facts, not values that change every reading.
iotclass.org

Major section

Read a Topic as a Public Contract (continued)

Putting 68.4 in a topic would create unbounded routes and make numeric filtering look like address selection.

  • A retained value can give a new dashboard the latest known state, but its observation time must reveal whether it is stale.
  • Redelivery can protect against loss, but a duplicate-safe topic consumer still needs a topic message identifier.
  • Those details make routing behavior reviewable after the subscriber list grows.
iotclass.org

Major section

Read a Topic as a Public Contract (continued)

A useful pub/sub release routing record includes topic examples, wildcard boundaries, payload schema, retained policy, delivery level, authorization rules, and evidence from an allowed and denied route.

  • One publish delivered to three subscribers is one observed sensor topic message and three deliveries, not three humidity measurements.
  • This distinction keeps volume dashboards and duplicate investigations honest.
  • An indefinite dual publish can double actions and conceal abandoned clients.
iotclass.org

Major section

Summary

In pub/sub, publishers send to named topics and the broker delivers copies to matching subscribers; neither side addresses the other, which is the model's strength and its contract risk.

  • A topic name is a routing contract: once consumers depend on it, the level order and meaning cannot change without breaking dashboards, automations, and bridges.
  • Wildcards + (one level) and # (trailing levels, last segment) are about matching; the real review question is whether the subscriber is authorized for everything the filter matches.
  • Fan-out turns one publication into many deliveries, so estimate it per topic family and bound the behavior when a consumer is slow or disconnected.
iotclass.org

Deck summary

Key takeaways

A broker is the service that matches a named message route to interested readers.

  • A match proves routing, not permission or useful action.
  • The publisher sends a routing record to a named topic rather than to a particular application.
  • A sensor publishes {"value":68.4,"unit":"%","observed_at":"10:05:20"}.
  • Putting 68.4 in a topic would create unbounded routes and make numeric filtering look like address selection.
iotclass.org

Retrieval practice

Recall check 1 of 3

Gateway Gus says: answer from memory, then check your reasoning.

Q1In publish-subscribe routing, how does a publisher reach a consumer?

ABy opening a direct request-response session with each consumer and waiting for an acknowledgement
BIt publishes to a topic; the broker matches subscriber filters and forwards copies
CBy requiring each consumer to poll the publisher device on a fixed collection schedule
DBy having the broker broadcast every publication to every connected client
Show answer

Answer: B Pub/sub decouples producers from consumers through topics and the broker's matching.

iotclass.org

Retrieval practice

Recall check 2 of 3

Gateway Gus says: answer from memory, then check your reasoning.

Q2A dashboard subscribes to 'plant-a/#' because it was easy during testing, but it only displays meter power values from one line. What is the best review action?

AKeep the broad filter because one subscription reduces the dashboard's configuration work
BSwitch the subscription to QoS 2 so the broad filter has stronger delivery semantics
CUse the narrowest authorized filter that covers only the required meter-power topics
DMove sensitive identifiers into the topic so the dashboard can filter them locally
Show answer

Answer: C A broad wildcard increases data exposure and fan-out; the filter should match only the required topic family within the authorization boundary.

iotclass.org

Retrieval practice

Recall check 3 of 3

Gateway Gus says: answer from memory, then check your reasoning.

Q3A team sets the highest QoS so that each command runs exactly once across the whole pipeline. Why is QoS alone not sufficient?

AQoS is not end-to-end exactly-once.
BThe broker's duplicate suppression covers command execution
CCommands need a retained state to complete delivery
DBecause raising QoS disables retained messages
Show answer

Answer: A End-to-end exactly-once is an application property built on idempotency and stable identifiers, not a guarantee a QoS level can provide on its own.

iotclass.org

Print reference

Answers

Answer key.

  1. B · Pub/sub decouples producers from consumers through topics and the broker's matching.
  2. C · A broad wildcard increases data exposure and fan-out; the filter should match only the required topic family within the authorization boundary.
  3. A · End-to-end exactly-once is an application property built on idempotency and stable identifiers, not a guarantee a QoS level can provide on its own.
iotclass.org