Skip to content

MQTT

MQTT binding。輸出的成員是 mqtt,每個物件都帶 bindingVersion: 0.2.0

@mqttServer

typespec
extern dec mqttServer(target: Namespace, config: valueof AsyncAPIMqttServerBinding);
欄位型別必填
clientIdstring
cleanSessionboolean
lastWillAsyncAPIMqttLastWill
keepAliveint32
sessionExpiryIntervalunknown
maximumPacketSizeunknown

套用在服務 namespace 上。該 namespace 宣告的每一個 server 各拿到一份。

lastWill 是用戶端未告別就離線時,broker 代發的訊息。它的 qos012。超出範圍的值會被回報並丟棄,遺言的其餘欄位保留。

sessionExpiryIntervalmaximumPacketSize 是 MQTT 5 欄位。寫成數字,或寫成描述該數字的 Schema Object。

@mqttOperation

typespec
extern dec mqttOperation(target: Operation, config: valueof AsyncAPIMqttOperationBinding);
欄位型別必填
qosint32
retainboolean
messageExpiryIntervalunknown

套用在帶有 @send@receive 的 operation 上。

qos012。其他值會被回報並丟棄。

@mqttMessage

typespec
extern dec mqttMessage(target: Model, config: valueof AsyncAPIMqttMessageBinding);
欄位型別必填
payloadFormatIndicatorint32
correlationDataunknown
contentTypestring
responseTopicunknown

套用在同時帶有 @message 的 model 上。四個欄位都是 MQTT 5 欄位。

payloadFormatIndicator0 表示未指定的位元組,1 表示 UTF-8。correlationData 是 Schema Object。responseTopic 是 topic 名稱,或描述該名稱的 Schema Object。