IMD SolutionComputing LibraryShop main store

Explainer

Why one MQTT view publishes all its tags in a single topic

Edge computing and IIoT Published 6 min read By IMD Solution engineering team

Short answer

Publishing a view over JSON MQTT sends one topic that carries the entire payload — 500 datapoints arrive as one message, not 500. Per-tag topics need a unique parent branch per tag plus untested publisher-session counts, so split the payload downstream or bridge the historian's read API — and never republish into a topic the collector logs.

On this page
  1. What one view publication puts on the broker
  2. The native drill-down limit
  3. Why per-tag publisher sessions stop scaling
  4. Worked example: sizing a read-API forwarder
  5. Splitting the payload downstream
  6. Keep republished values out of the historian
  7. The decision, case by case
  8. Questions asked

Publishing a Canary view over JSON MQTT does not fan out per tag. A view holding 500 datapoints lands on the broker as exactly one topic, carrying one JSON payload that contains every datapoint, and each update cycle republishes the entire structure. There is no switch that turns each datapoint into its own topic. The publisher's only native narrowing is path drill-down, and it produces one tag on one topic only when every tag sits under its own unique parent branch — an arrangement that multiplies publisher sessions into a range nobody has tested. For more than a few dozen tags, split the payload downstream or bridge the historian's read API instead, and never republish into a topic the collector already logs, or the historian will ingest its own output.

What one view publication puts on the broker #

The publication is keyed to the view, not to the tags inside it: one topic name, one message body, every datapoint in it. A consumer such as Node-RED triggers once per publication and has to distribute individual values to its own flows internally — which is exactly why per-tag topics get requested.

The broker sees few messages, but each message grows with the view. Add datapoints and every subscriber downloads values it may not use, and no topic-level access control can shield a single tag, because no tag has a topic of its own. That last point, not bandwidth, is usually the real driver behind a one-topic-per-tag request.

The native drill-down limit #

The publisher can drill all the way down the tag path, excluding the tag name itself. The topic therefore comes from the branches above the tag, so for a single tag to sit alone on a single topic, the branch immediately above it must hold only that tag. Every tag needs a unique parent branch, and reshaping the historian namespace becomes the MQTT routing design: you organize the tag tree so the topic tree comes out the way consumers need it. The same one-branch-per-entity discipline governs other plant MQTT tooling — why MQTT Engine needs unique Group and Edge Node IDs is the same rule biting elsewhere.

Goal What you configure Limit or cost
Publish the whole view JSON publication of the view One topic carries all datapoints; subscribers split the payload
One tag on one topic Path drill-down, excluding the tag name Every tag needs a unique parent branch above it
A few dozen isolated tags One publication per isolated tag Workable, but pilot the exact session count first
Hundreds of isolated tags The same arrangement, scaled up Session counts at that size were never tested
Estate-wide isolation No publisher-side configuration exists Parse the payload downstream or bridge the read API

Why per-tag publisher sessions stop scaling #

Path drill-down with a unique branch per tag means one publication, and its publisher session, per isolated tag. The session count scales with the tag count, and the evidence on this arrangement is explicit: sessions in the hundreds were reported as untested, and the 20,000-tag plan behind the question was judged not feasible this way. Treat that as the documented envelope — hundreds of sessions are unverified, and tens of thousands are out. The decision is blunt: above a few dozen tags, do not build per-tag topics on publisher sessions. Put the fan-out where it scales — downstream parsing, or a forwarder on the historian's read API.

Worked example: sizing a read-API forwarder #

A forwarder inverts the problem. Instead of pushing sessions out of the publisher, it calls the historian's read API — the live data endpoints — and republishes each tag on a topic built from that tag's exact tag path. Point it at a dedicated view containing only the tags you want on the broker, and the topic tree comes straight out of the tag paths.

A community-built forwarder doing exactly this reported about 300 tags moved per one-second cycle in its builder's limited testing, with bursts up to 5,000 tags. Treat that as a reported figure from limited testing, not a vendor rating.

Sizing arithmetic for an estate of 20,000 tags:

  • Full sweep at the reported pace: 20,000 tags ÷ 300 tags per cycle = 66.7 cycles, so a complete refresh takes about 67 seconds at one-second cycles.
  • Burst pacing: the estate ÷ 5,000 tags per burst = 4 cycles as the fastest possible full refresh at that burst size.
  • Parallel instances divide the sweep roughly by their count, assuming the API keeps up: 66.7 ÷ 4 ≈ 16.7, so four instances bring the full sweep to about 17 seconds.

What moves those numbers: API latency, the view size each instance reads, broker round-trip time, and whether the endpoints allow authenticated access. Today this forwarder approach requires anonymous access enabled on the read API, which is an unauthenticated read path into your historian — keep the forwarder, the broker and the historian API on a restricted network segment of their own, or hold production tags back until authenticated access is supported. The forwarder itself is a small always-on service, and a fanless industrial mini PC on the plant network is the kind of host that runs it.

Splitting the payload downstream #

If the consumers can live with one topic, keep the single publication and split the JSON at the subscriber: one session, one message per cycle, no namespace surgery, and scaling that follows the consumer's CPU instead of publisher sessions. That is the pattern in writing tags on an edge gateway from an MQTT JSON payload. Design out two parsing traps. A publisher that sends only changed values produces partial payloads, and why a partial MQTT payload hides your second value traces what that does to the values you thought you had. Array-valued datapoints need explicit index handling on the subscriber side, never a whole-array dump into one field.

Keep republished values out of the historian #

If the forwarder publishes into a topic space the MQTT Collector already subscribes to for logging, every republished value flows straight back into the historian, because the collector cannot tell a source value from your own publication. Fix it structurally first: publish under a branch the logging subscription does not cover. If the plant hierarchy looks like enterprise/site/line1, put forwarder output on a sibling branch such as enterprise/site/line1/bridge and scope the subscription to exclude it. Where topic spaces genuinely must overlap, add logic in the collector's JSON processing that excludes the outgoing tags before they are logged. Verify with one value: change a single source tag, confirm exactly one publication on the broker and exactly one ingestion into the historian, then repeat the test after a broker restart.

The decision, case by case #

  • Consumers that can parse JSON: keep one topic and split downstream. One session, one message per cycle, no untested session counts. This is the default.
  • A handful of tags that genuinely need their own topics: drill the tag path, give every tag a unique parent branch, and pilot the exact session count before trusting it in production.
  • Hundreds of tags or more on the broker: build the read-API forwarder, size it against the sweep arithmetic above, and shard it across instances when the sweep is too slow. Do not build this with per-tag publisher sessions.
  • Any publication into a logged topic space: separate the topic space or filter the collector first, and let no republish go live before the one-value change test passes.

One topic carrying everything, parsed downstream, is the architecture that survives a real deployment; per-tag topics are a small-view luxury, and the read API is the only route that scales.

Questions asked

Can a view put every datapoint on its own MQTT topic?

Not directly from the view. A JSON publication sends the entire datapoint set in one payload, and the publisher's path drill-down stops short of the tag name, so one tag on one topic requires a unique parent branch above every tag. Plan for two consequences: publisher sessions grow with the tag count in an arrangement never tested at scale, and renaming any parent branch changes the topic name, which silently breaks consumers keyed to the old topic.

How fast can a read-API forwarder republish tags to MQTT?

A community-built forwarder using the live data endpoints reported about 300 tags per one-second cycle in limited testing, with bursts up to 5,000 tags. At that pace a 20,000-tag estate needs about 67 seconds for a full sweep, and each added instance divides the sweep roughly by its count. Treat the pace as a reported figure, not a vendor rating, and watch broker queue depth during bursts.

How do I stop a published MQTT value from looping back into the historian?

Do not republish into a topic the MQTT Collector subscribes to for logging. Either move forwarder output to a branch outside the logging subscription, or add logic in the collector's JSON processing that excludes the outgoing tags before they are logged. A loop shows up as republished values reappearing in the historian with fresh timestamps; confirm the fix by changing one source value and counting publications and ingestions.

Keep reading

  • Troubleshooting

    Why two Telegraf MQTT inputs share one client ID and disconnect

    Both [[inputs.mqtt_consumer]] blocks carry client_id = "Telegraf", and the MQTT specification allows only one active connection per client identifier. Each connection displaces the other at the broker, producing the EOF and reconnect loop. Give each block a distinct client_id and leave the parsers and topics alone.

    Edge computing and IIoT

  • How-to

    Write tags on an edge gateway from an MQTT JSON payload

    Yes. Subscribe the gateway to one command topic with QoS 0, publish a flat JSON object whose property names match tag names exactly, and run a BASIC callback that splits the payload at commas, writes strings directly when the tag type is "6", converts numerics through VAL, and skips any name that fails to load with LSTERR -4.

    Edge computing and IIoT

  • How-to

    Combine two MQTT sensor inputs in one Node-RED calculation

    Node-RED accepts many wires into one node but delivers each message separately, so combine the two MQTT streams explicitly. Use a Join node in manual mode with a message count of 2 and msg.topic as the key, or a Function node that stores the latest temperature and smoke flag in context and evaluates both on every arrival.

    Edge computing and IIoT

Why Tier 2 historian replication loses the asset hierarchy view