YOUSEFUL / DELPHI / COMPONENTS
TMqttQoS
Quality of service: at most once, at least once, exactly once.
Description
TMqttQoS = (qosAtMostOnce, qosAtLeastOnce, qosExactlyOnce);The ordinal values 0, 1 and 2 are the MQTT quality levels. Declared in Atlas.MqttCodec, so add that unit to uses wherever you name a value. A message is delivered at the lower of the quality it was published with and the quality of the subscription.
Members
| Member | Kind | What it does |
|---|---|---|
qosAtMostOnce | value | Quality 0: sent once, never acknowledged or repeated. |
qosAtLeastOnce | value | Quality 1: repeated until the receiver answers PUBACK. |
qosExactlyOnce | value | Quality 2: a four-step exchange (PUBLISH, PUBREC, PUBREL, PUBCOMP) that delivers exactly once. |
Values
qosAtMostOnce value
qosAtMostOnceQuality 0: sent once, never acknowledged or repeated. Cheap, and lost if the connection drops at the wrong moment. TAtlasMqttClient.Publish refuses it while offline.
qosAtLeastOnce value
qosAtLeastOnceQuality 1: repeated until the receiver answers PUBACK. It may arrive more than once, for example after a reconnect.
qosExactlyOnce value
qosExactlyOnceQuality 2: a four-step exchange (PUBLISH, PUBREC, PUBREL, PUBCOMP) that delivers exactly once. Atlas MQTT suppresses a repeated quality-2 message on both the client and the broker side.
Examples
A quality from a stored setting
The values are ordinals 0 to 2; anything else is refused.
uses
Atlas.MqttCodec;
function QualityFromSetting(Value: Integer): TMqttQoS;
begin
if (Value < Ord(Low(TMqttQoS))) or (Value > Ord(High(TMqttQoS))) then
raise EAtlasMqttError.CreateFmt('Quality %d does not exist in MQTT 3.1.1', [Value]);
Result := TMqttQoS(Value);
end;Related
TAtlasMqttClient · TMqttPacket