Explainer
Why a partial MQTT payload hides your second value
Short answer
MQTT has no field merging: a broker forwards each payload as one complete message, so a receiver that replaces its whole record on every publish drops any value omitted from that publish. Fix it with Sparkplug B-aware ingestion, one topic per value, or a snapshot rebuilt from retained last-known values.

On this page
An MQTT broker never merges payloads. Whatever the publisher sends arrives at the subscriber as one complete message, and a receiver that treats every message as a full replacement of its stored record loses any value that publish left out. That is why machine2 vanishes from your application a few seconds after it appears: machine1 updates far more often, each machine1-only publish overwrites the last record, and machine2 comes back only when its own change happens to land in the same payload. The broker is doing its job correctly; the receiver is using the wrong state model. Three fixes work: keep Sparkplug B-aware ingestion end to end, publish each value on its own topic, or rebuild a full snapshot from retained last-known values before handing it to the application.
A topic is an address, not a record #
An MQTT topic routes a sequence of messages. The broker delivers each payload according to subscription and delivery settings and does not interpret the machine names or fields inside it, so there is no mechanism that preserves an omitted field from the previous message. Finer-grained meaning, as the MQTT documentation puts it, is agreed between publishers and recipients in the payload itself.
Sparkplug B adds that agreed meaning as an application-level state model. A birth message establishes the full metric baseline for a node or device; subsequent data messages carry report-by-exception updates, meaning only metrics that changed. A compliant receiver therefore maintains current values across messages: a metric omitted from a data message keeps its last known value and is never deleted or blanked. Sparkplug B's own description of the data message defines it exactly this way, published when device metric values change.
Your symptom is the mismatch between those two models. A generic MQTT input that decodes each payload and stores it whole answers the transport question correctly and still fails the state question, because it replaces the whole machine record on every partial update.
A worked example of how the value disappears #
Say machine1 changes every 5 seconds and machine2 changes every 300 seconds, and both publish onto one Sparkplug B topic with a receiver that stores the whole decoded payload.
- At 12:00:00 machine2 changes and lands in a publish alongside a machine1 change: the stored record holds both values.
- From 12:00:05 to 12:04:55, fifty-nine machine1-only publishes arrive. Each one replaces the record, so machine2 is absent from the stored state for 4 minutes 55 seconds after its value was current.
- At 12:05:00 machine2 changes again and reappears, then vanishes again for another 295 seconds of machine1-only traffic.
Your application sees machine2 publish roughly every 300 seconds and show for one update cycle, then disappear, which matches what you described. The publish rate was never wrong; the receiver's retention was.
Where the failure sits on the data path #
Trace publisher, broker, receiving application, displayed values in that order. Before changing payload structure, confirm delivery: check connection status on both ends and compare messages a broker-facing diagnostic client sees with what the application logs. Two cautions apply. A connected diagnostic client proves only its own path and subscription, not the application's. And a slower update rate is not evidence that machine2 stopped publishing; report-by-exception means silence is normal for an unchanged value.
| Symptom | Mechanism to investigate | Decisive check |
|---|---|---|
| A value appears only when both change together | Receiver treats each payload as a full replacement | Compare consecutive decoded messages against the receiver's stored values |
| A Sparkplug-aware receiver keeps the value, the other application does not | The other receiver lacks state reconstruction | Run both receivers during a machine1-only update |
| The application misses messages another subscriber sees | Subscription or ingestion failure | Compare topic filters, connection events and receive logs |
| Values stay missing after reconnection | No fresh baseline recovered | Check birth processing and host-state recovery configuration |
If the diagnostic client and the live articles' expected Sparkplug message timing both look correct, the failure is the application's payload handling, and the fix is one of the three below.
Fix 1: keep Sparkplug B end to end #
The cleanest fix is to make the receiving side protocol-aware. Use a Sparkplug B receiver or ingestion module that decodes birth and data messages and maintains metric state, such as a host application's Sparkplug engine module. Configure the Primary Host ID identically at the publisher and the host so that a lost connection triggers rebirth: publishers resend birth messages carrying all current values, giving the receiver a complete baseline. Then test the rebirth path by deliberately disconnecting and reconnecting a component, rather than trusting matching configuration text; recovery also depends on working subscriptions and correct lifecycle processing.
This preserves the point of report-by-exception publishing instead of raising traffic to compensate for a receiver that cannot hold state.
Fix 2: publish each value on its own topic #
If the application cannot consume Sparkplug B and you control the publisher, move to a custom namespace with one topic per value. Each topic then holds exactly one latest value, so no publish can overwrite a sibling. You take on application-defined semantics for freshness and connection state that Sparkplug B would otherwise provide. Note that the alternative of "more topics so they don't overwrite each other" is precisely this: the leaf topics must be separate, not two fields in one payload.
Fix 3: rebuild a complete snapshot before ingestion #
If you must keep one topic, put a small protocol-aware stage between the broker and the application: a subscriber that holds the last known value of every metric and republishes a full snapshot containing all values on every update, or on a fixed interval. The critical rule is that the snapshot must be assembled from retained last-known values. Forwarding the most recent raw payload reproduces the failure exactly, because it is still partial. For Sparkplug B sources, an edge application or gateway that already maintains the metric state can do this republishing.
The decision for each case #
If your application has, or can add, Sparkplug B-aware ingestion, use it: keep report-by-exception publishing, match the Primary Host ID, and verify rebirth by a controlled disconnect test. If the application only maps individual inputs and you control the publisher, split machine1 and machine2 onto separate topics so neither can overwrite the other. If you are stuck with one topic and a snapshot-only application, insert a stage that rebuilds the full record from last-known values and republishes it whole; never forward partial payloads. What not to do: leave a generic payload receiver in place and hope a slower update rate fixes it. With machine1 at 5 seconds and machine2 at 300 seconds, the record will keep losing machine2 for all but one cycle in sixty regardless of how long you wait.
For the surrounding ingestion path, the pieces that matter most are where a Sparkplug node sends DBIRTH once and DDATA only on change, which is exactly why partial payloads are normal and expected; the host-side rebirth behavior you rely on in fix 1; and how an ingestion application can ignore DDATA after a DBIRTH when its state handling is incomplete, the same class of receiver-side bug as this one.
One safety note: fixes 2 and 3 change where control or alarm logic reads its values. Before switching an application from a partial feed to a rebuilt snapshot or new topics, confirm that any value used for an operator decision or a protective action keeps its stale-marking behavior, so an old number is never presented as a fresh measurement.
When the fix ends up living on an edge box rather than the application server, a fanless mini PC is the usual host for the broker-side stage that rebuilds the snapshot.
Related reading on this site: Why Sparkplug B sends DBIRTH once and DDATA only on change covers the report-by-exception timing that makes partial payloads normal, Rebirth fails after switching Sparkplug MQTT brokers covers the host-state recovery that fix 1 depends on, and Why an MQTT collector logs DBIRTH but ignores DDATA covers the receiver-side state bug in its collector form.
Questions asked
Does an MQTT broker merge fields from consecutive messages on the same topic?
No. The broker forwards each published payload as one complete message according to the subscription and delivery settings. It does not parse machine names or metric names inside the payload, so it cannot keep a field from an earlier message and attach it to a newer partial one. Merging is the receiver's job, and a Sparkplug B-aware receiver does it using birth and data messages.
Why does the value show in MQTT Explorer but disappear in my application?
MQTT Explorer shows the latest message received on the topic; your application is expected to build a running state instead. If the application replaces its stored record with each incoming payload, any value omitted from a partial publish vanishes from its view until the next publish that includes it. A diagnostic client proving delivery does not prove the application is decoding and retaining state correctly.
What is the Primary Host ID for in Sparkplug B?
It is a recovery coordination identity, not a payload-formatting setting. When the host application and the publishing edge nodes are configured with the same Primary Host ID, a lost connection triggers a rebirth so the publishers resend birth messages with all current values. That gives the receiver a complete fresh baseline instead of waiting for each metric to change on its own.


