feat(mqtt): Sparkplug primary-host STATE publishing (ActAsPrimaryHost)
#511
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
MqttSparkplugOptions.ActAsPrimaryHost(Driver.Mqtt.Contracts/MqttDriverOptions.cs:193) is accepted byconfig and by the AdminUI driver form, but does nothing. Setting it logs a startup warning
(
MqttDriver.cs:933) rather than sitting silently inert.Why it shipped unimplemented rather than half-implemented. Being a Sparkplug primary host is a three-part
contract:
STATEmessage assertingONLINE,OFFLINEregistered as the MQTT Last Will, at connect time,OFFLINEpublished on clean shutdown.Shipping (1) without (2) is strictly worse than shipping neither: a crashed node leaves a retained
ONLINEon the broker asserting forever that a dead host is alive, and edge nodes trusting that assertion will not
take their own offline actions. The warning is the deliberate middle ground.
Extra consideration for this server: both redundancy pair nodes subscribe independently (MQTT fan-out is
per-connection, and the Primary gate applies downstream of ingest, not to it). Two nodes both claiming primary
host on the same host id would fight over the retained
STATE. An implementation must decide whetherprimary-host duty is Primary-gated — and if it is, whether a failover republishes
ONLINEfast enough toavoid an edge-visible flap.
Acceptance. With
ActAsPrimaryHost: true, the broker holds a retainedONLINEwhile the node runs; akill -9of the node leavesOFFLINE(the Will fires); a clean shutdown leavesOFFLINE. Verified liveagainst the Mosquitto fixture, and the pair-node question answered explicitly rather than left to chance.