MQTT and Sparkplug B Consumers
Publishing to a broker — topic and payload formats, placeholders, and the Sparkplug group and node identity.
The MQTT Broker and SparkplugB Broker consumers publish Infohub's values to a broker, where any number of subscribers can consume them. This is the natural route into an IIoT architecture, and it is how Infohub feeds systems that prefer a stream to a query.
Consumer, not data source. Infohub has MQTT in both directions. The MQTT data source subscribes — data flows in. The MQTT Broker consumer described here publishes — data flows out. See MQTT and Sparkplug B for the inbound direction.
Connection properties#
| Property | Notes |
|---|---|
| MQTT Server, MQTT Port | The broker |
| Protocol | Plain MQTT or Sparkplug B |
| Mqtt Version | Protocol version |
| TLS, SSL Protocol | Transport encryption |
| Certificate Store, Certificate Name | Client certificate |
| Username / Password | Broker credentials |
| Quality of Service | Delivery guarantee |
| Group ID, Node ID | Sparkplug identity |
| Topic Format | How topics are constructed |
| Payload Format | How the message body is constructed |
| Path | Base path |
Topic and payload formats#
These two properties are where the design work happens, and they are what makes the consumer flexible enough to fit an existing broker convention rather than imposing one.
Both are templates. Rather than publishing a fixed shape, you describe the topic a value should go to and the body it should carry, and Infohub substitutes per measure.
Placeholders let the model's own structure drive the topic — model attributes in particular, so the topic reflects the plant hierarchy:
plant/[ModelAttribute("Area")]/[ModelAttribute("Line")]/<measure>
A [Version] placeholder is also available in custom topic and payload formats, which is new in 7.2.0. It lets subscribers distinguish payload revisions — useful when you need to change the payload shape without breaking existing consumers, because they can key off the version rather than guessing.
Agree the topic convention with the broker's owner first. A broker usually has an established namespace convention, and publishing into it incorrectly is disruptive in a way that a badly named SQL table is not — every subscriber sees it. Get the intended topic structure from whoever owns the broker, then build the Topic Format to match it, using model attributes so it scales across the model.
Keep the payload as simple as the subscribers need. A JSON body with a value, a timestamp, and a quality is easy for anything to consume. An elaborate nested structure is harder for every subscriber and provides no benefit unless something actually reads the extra fields.
Timestamps in the payload#
Publish timestamps unambiguously. Two decisions:
Units. If publishing epoch values, be explicit about seconds or milliseconds and document it. Subscribers cannot tell from the number, and getting it wrong puts values decades away.
Time zone. Publish UTC, or include an explicit offset. A timestamp with no offset is ambiguous, and every subscriber will resolve the ambiguity differently.
These are the same problems the MQTT data source faces reading other people's payloads. Having experienced it from the consuming side is a good argument for being precise on the publishing side.
Sparkplug B#
Selecting Sparkplug as the Protocol switches to that specification's conventions: a standardised topic structure, encoded payloads, birth and death certificates, and sequence numbering.
Group ID and Node ID establish Infohub's identity in the Sparkplug namespace. These are not free-form labels — they position Infohub within the plant's Sparkplug topology, and they must be agreed with whoever governs it. Two publishers claiming the same group and node identity will confuse every subscriber.
Choose Sparkplug when the plant has adopted it. Its advantages — automatic discovery, state awareness, defined semantics — only exist if subscribers expect it. Publishing Sparkplug into an environment where nothing speaks it adds complexity for no benefit, and plain MQTT with a well-designed topic structure is the better choice there.
Quality of Service#
MQTT's delivery guarantees, from at-most-once to exactly-once. Higher levels cost broker resources and latency.
For reporting data published every interval, the middle ground is usually right: losing a message occasionally is tolerable because the next one supersedes it, and the values remain available in Infohub regardless. For values a downstream control decision depends on, raise it.
Note that QoS governs delivery while connected. It does not replay messages published while a subscriber was absent — that is the subscriber's problem, and it is why a broker is not an archive.
Security#
Brokers are frequently reachable more widely than databases, so treat this properly:
- Enable TLS, and pin the SSL protocol to a current version.
- Use a dedicated credential for Infohub's publishing, not a shared one.
- Grant publish rights only to the topics Infohub uses, and no subscribe rights at all. A publisher credential that can also subscribe, or publish anywhere, is a wider hole than it needs to be.
- Use client certificates where the broker supports them.
Volume#
A broker sees every value you publish. Do the arithmetic: a thousand measures at hourly intervals is 24,000 messages a day, and at minutely intervals it is 1.4 million.
Publish what subscribers need, at the interval they need it. Publishing a minutely measure to a broker whose subscribers report daily is a great deal of traffic for no benefit — and the namespace filter is the tool for narrowing it.
Also remember that restatements republish. A backfill in Infohub produces a burst of messages for historical periods, which subscribers expecting only current values may handle badly. Warn them, or exclude backfilled periods from publication.
Diagnosing#
| Symptom | Check |
|---|---|
| Nothing published | Integration Engine and consumer both deployed? |
| Cannot connect to broker | Address, port, TLS and SSL protocol agreement, credentials |
| Publishing refused | Credential lacks publish rights on those topics |
| Topics not where subscribers expect | Topic Format; confirm the convention with the broker's owner |
| Subscribers cannot parse the payload | Payload Format; capture an actual published message and check it |
| Timestamps misread by subscribers | Units or missing time zone offset |
| Sparkplug subscribers confused | Group ID and Node ID colliding with another publisher |
| Sudden flood of messages | A backfill in Infohub republishing history |
| Broker under load | Publishing too many measures, or at too fine an interval |