TsgcWSPClient_MQTTProperties › LastWillTestament

LastWillTestament Property

Registers a Will message the broker publishes on behalf of this client if the connection is lost ungracefully.

Syntax

property LastWillTestament: TsgcWSMQTTLWT_Options read FLastWillTestament write SetLastWillTestament;

Default Value

Enabled=False, Topic='', Text='', QoS=mtqsAtMostOnce, Retain=False

Remarks

Set LastWillTestament.Enabled to True to include the Will flag and Will payload in the CONNECT packet. The broker stores the message and publishes it on the given Topic if the client disconnects without sending a clean DISCONNECT (network failure, crash, keep-alive timeout). Topic is mandatory when enabled. QoS accepts mtqsAtMostOnce, mtqsAtLeastOnce or mtqsExactlyOnce. Set Retain=True to ask the broker to retain the Will for future subscribers. (MQTT 5.0) WillProperties exposes WillDelayInterval, PayloadFormat, MessageExpiryInterval, ContentType, ResponseTopic, CorrelationData and UserProperties; on MQTT 3.1.1 these fields are ignored.

Example


MQTT.LastWillTestament.Enabled := True;
MQTT.LastWillTestament.Topic := 'devices/sensor-01/status';
MQTT.LastWillTestament.Text := 'offline';
MQTT.LastWillTestament.QoS := mtqsAtLeastOnce;
MQTT.LastWillTestament.Retain := True;

Back to Properties