IMD SolutionComputing LibraryShop main store

Explainer

Why MQTT Transmission script publish skips the History Store

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

Short answer

Yes: the History Store never buffers messages from system.cirruslink.transmission.publish. Store-and-forward belongs to Transmitters and the Sparkplug Edge Nodes created from them, and the call is fire-and-forget with no delivery result. For durable event delivery, either move the events into a transmitter-owned tag path or persist them in a queue you own before any transport call.

On this page
  1. What the publish call actually does
  2. Why the History Store never sees the message
  3. What the call returns, and what that proves
  4. Why QoS and retained do not help
  5. What an outage costs, in numbers
  6. The two designs that do buffer
  7. The decision for each case
  8. Questions asked

Yes, it is true: the History Store configured beside your transmitter will never buffer a message sent with system.cirruslink.transmission.publish. Store-and-forward in the MQTT Transmission module for Ignition 8.1 belongs to Transmitters and to the Sparkplug Edge Nodes created from those Transmitters, and the scripting call goes around that data path entirely. It is also fire-and-forget: the function returns no delivery result your script can test, so a completed call during an outage looks exactly like a completed call online. If buffering is a requirement, you have two honest designs, and this article gives you the mechanism, the arithmetic and the decision for each case.

What the publish call actually does #

The call is system.cirruslink.transmission.publish(mqttServerName, topic, payload, qos, retained). It names an MQTT server configuration, supplies the topic and payload, and applies the requested QoS and retain flag. The module then attempts the publication over the configured connection to that broker. With the path up, the broker receives your JSON, and that part of your setup works. With the broker unreachable, the publication is simply gone: no local record, no retry, no entry in the History Store.

The shape is the familiar one-shot publish pattern. The Eclipse Paho Python client documents the same behavior for its single-message helper, which creates a client, connects to a broker, publishes one message and disconnects cleanly. Nothing in that shape stores anything for later, and the MQTT Transmission scripting call adds no queue of its own.

Why the History Store never sees the message #

The module's documented scope is narrow: store-and-forward applies to Transmitters and the Sparkplug Edge Nodes created from those Transmitters, and the publish scripting API does not use or support it. The configuration tells the same story. The store's History Settings live in the module's Transmitters tab, as a property of a transmitter, so the store belongs to that transmitter's data path and only data entering through an object the transmitter owns can reach it.

Publishing path Relationship to the History Store While the broker is unreachable
A Transmitter and its Sparkplug Edge Node Uses the transmitter's store-and-forward Data is recorded and backfilled after reconnect
system.cirruslink.transmission.publish(...) Does not use or support store-and-forward The publication is lost; nothing is queued

So a History Store sitting next to your transmitter does not become a general-purpose queue for arbitrary script calls. This is an architectural boundary, not a malformed topic or a payload problem. When the transmitter path does buffer, the replay after reconnect is its own behavior with its own limits, covered in MQTT store and forward backfill after a connection outage.

What the call returns, and what that proves #

The function hands the publication to the module and returns no usable success or failure to the scripting layer. A completed call therefore proves exactly one thing: your script invoked the API. That single fact drives the whole design. Code that deletes a queued record right after the call loses that record during an outage, because the call completes the same way it does online. Code that retries on the call's return has no failure signal to retry on.

Signal It proves It does not prove
The function call completes The script invoked the publishing API Broker receipt or processing
The broker log shows the publication The broker accepted that topic and payload Downstream application processing
An acknowledgment names the event identifier The consumer stage you defined handled that event Any stage beyond that contract
retained is enabled The broker may hold the last received publication for late subscribers Anything before broker receipt

Durable delivery therefore needs an acknowledgment your application defines: an identifier on every event, carried back on a return topic or through another customer-approved confirmation. Because a timeout can trigger a retry after the first copy was already processed, the consumer must absorb duplicate identifiers.

Why QoS and retained do not help #

Retain controls what the broker does with a publication after it receives it; it cannot preserve a message that never reaches the broker. QoS 1 is a handshake inside a live MQTT session: with no connection there is no handshake, and with no result returned your script owns no retry decision. Neither mechanism stores anything locally before the broker accepts. One line to hold onto: keep interlock and safety events off this path altogether, because a fire-and-forget publish is a notification, never a safety function, and the machine's protection must not depend on an MQTT message arriving.

What an outage costs, in numbers #

A worked example, so you can size the fix. Take a packing-line gateway that publishes one JSON event per finished case at an average of 20 events per minute, each payload about 450 bytes. During a switch replacement the broker is unreachable for 4 hours.

With the bare call, the whole production record for the window is lost: 20 events/min × 60 min/h × 4 h = 4,800 events, with no local trace to recover from.

With an application-owned queue, each record is the payload plus an envelope of about 200 bytes (identifier, topic, timestamp, state): 450 B + 200 B = 650 B per record, so 4,800 records × 650 B = 3,120,000 B, about 3.1 MB. On any industrial gateway's storage that is negligible; the constraint is the design, not the disk. After the connection returns, draining at 100 messages per second takes 4,800 ÷ 100 = 48 s, so the consumer sees a short, bounded backlog.

Run the same arithmetic for the outages you will actually see. A 50-second blip at that rate costs 20 ÷ 60 × 50 ≈ 17 events, small enough to miss entirely if you never test the offline branch.

The two designs that do buffer #

Design A: put the events on the transmitter's path. Write each event's JSON to a tag that a Transmitter's Sparkplug Edge Node publishes with history enabled. The store then holds changes through the outage and backfills on reconnect. Choose it when the customer broker consumes Sparkplug and the events can live as tag data.

Read the replay behavior before you commit; start with why a short MQTT outage resends 24 hours of history. In one documented case MQTT Transmission history is lost after a 50-second outage, so the store is not a set-and-forget answer either. Design the consumer for replayed data: on other edge gateways the same split appears, where buffered replay arrives on a separate publish topic, so the receiving end must subscribe to both the live and the replay flow.

Design B: own the queue. This is the right design when the events are bespoke JSON on topics the customer defines, which is the common case for this function:

  1. Persist each event before any transport call: identifier, destination topic, payload, timestamp and state, in a durable local store. A SQLite table is enough at the sizes above.
  2. Define the delivery boundary, broker acceptance or application processing, and write it down.
  3. Attempt pending records only while the connection is available, and complete a record only when the acknowledgment matching that boundary arrives.
  4. Preserve ordering if the consumer depends on sequence, and make the receiver absorb duplicate identifiers.
  5. Test it. Online, confirm one event's topic, payload and identifier at the boundary. Take the broker offline, create events and confirm every one stays pending locally. Restore, run the retry worker and confirm the drained count equals the pending count.

REST fits here as a transport swap, not a fix. An HTTP response gives the script a status it can branch on, which solves the no-result problem, but a down endpoint still fails the request, so the same persisted queue sits behind it either way.

The decision for each case #

  • Event-driven JSON to a customer broker, outages expected: build Design B. Persist before the call, complete on acknowledgment, and never delete a record on the function's return. This is the design that meets the buffering requirement today.
  • The consumer takes Sparkplug: move the events onto a transmitter-owned tag with history enabled and let the store work. Least code, vendor-supported buffering, once you have read its replay behavior.
  • Occasional, low-value notifications, such as a dashboard alert nobody audits: the bare call is acceptable. Say that out loud in the design document so nobody later assumes durability.
  • In every case: design to the behavior documented for the module version you deploy. If a future release documents a delivery result for this call, prove it with the offline test above before you trust it.

Questions asked

Does QoS 1 on the script publish make it durable?

No. The QoS 1 handshake runs inside a live MQTT session, and it is the client implementation that holds and retries unacknowledged messages. This call gives your script no session to supervise and no result to act on, and during a broker outage there is no handshake at all. QoS raises delivery effort between a connected client and the broker; it never creates local persistence.

Would the REST API be a better path for these events?

Only as a transport swap. An HTTP response gives the script an acceptance status it can branch on, which fixes the no-result half of the problem. It does not fix persistence: when the endpoint is down the request fails and the event is gone unless you stored it first. Choose REST when the customer's endpoint is HTTP, and keep the same persist-first queue behind it.

If I enable history on a tag, do script-published events get stored?

Only when the event travels as that tag's value through a transmitter's edge node. History records changes of a tag's value; a JSON string your script sends straight to a topic never becomes a tag value, so no history record and no store entry exists for it. To use the store, the event has to enter through an object the transmitter owns.

How do I test both offline branches?

Take the broker down two different ways. Stop the broker service to exercise the connection-refused branch, then pull the gateway's network cable to exercise the established-session-dropped branch; they fail at different layers and your queue must survive both. In each run, count events created, records left pending and events received after reconnect, and reconcile all three before sign-off.

Can I delete from my queue right after the function returns?

No. The return proves only that the script invoked the publishing API, and during an outage the call completes exactly as it does online. A delete-on-return design therefore empties the queue at the moment nothing was delivered. Complete a record only when an acknowledgment carrying that event's identifier arrives from the delivery boundary you defined.

Keep reading

  • Selection guide

    Choosing an edge data path for periodic records

    For independent periodic samples, Tag Historian with Edge Sync Services is the reliable path and buffers 35 days locally. For one atomic row per collection cycle, use MQTT Transmission records landing in MQTT Recorder. For true transaction groups, license a standard gateway for that node.

    Edge computing and IIoT

  • Troubleshooting

    Trace Ignition Edge MQTT values that only update on refresh

    Values that appear only after a refresh mean the Edge transmitter publishes nothing on its own: the forced republish masks a stalled change-driven path. Set a 10,000 ms scan rate with a 0.00000001 deadband and a moving signal publishes at the scan rate, then verify by counting 6 updates per minute with no refresh anywhere. Trace tag value and timestamp at each hop to find where it stops.

    Edge computing and IIoT

  • Troubleshooting

    Why MQTT Transmission does not publish new calculated tags

    MQTT Transmission treats a newly created calculated tag as a change to the Sparkplug metric model and never rescans on its own, so the tag stays unpublished until a refresh republishes the Edge Node BIRTH. Watch the Refresh Required tag in the Transmission Control folder and write True to Refresh from a gateway script on its rising edge, batching bulk tag edits into one refresh.

    Edge computing and IIoT

Why oversized history blocks spike historian RAM at merge