共用方式為


MQTT 路由訊息的事件架構

MQTT 訊息會根據下列邏輯路由傳送至事件方格主題作為 CloudEvents:

針對承載格式 indicator=0 的 MQTT v3 訊息或 MQTT v5 訊息,承載將會在 data_base64 物件中轉送,並根據下列架構範例編碼為base 64 字串。

{
	"specversion": "1.0",
	"id": "9aeb0fdf-c01e-0131-0922-9eb54906e20", // unique id stamped by the service.
	"time": "2019-11-18T15:13:39.4589254Z", // timestamp when the message was received by the service.
	"type": "MQTT.EventPublished", // set type for all MQTT messages enveloped by the service.
	"source": "testnamespace", // namespace name
	"subject": "campus/buildings/building17", // topic of the MQTT publish request.
	"data_base64": 
    {
		IlRlbXAiOiAiNzAiLAoiaHVtaWRpdHkiOiAiNDAiCg==
	}
}

針對內容類型為 「application/json」 的 MQTT v5 訊息;charset=utf-8“ 或承載格式 indicator=1,承載將會在數據對象中轉送,而訊息將會串行化為 JSON(如果承載不是 JSON,則為 JSON 字串)。 設定內容類型和/或承載格式指標可讓您篩選承載屬性,因為承載在數據欄位內轉送為目前。 深入瞭解如何 篩選訊息的承載。

{
	"specversion": "1.0",
	"id": "9aeb0fdf-c01e-0131-0922-9eb54906e20", // unique id stamped by the service.
	"time": "2019-11-18T15:13:39.4589254Z", // timestamp when the message was received by the service.
	"type": "MQTT.EventPublished", // set type for all MQTT messages enveloped by the service.
	"source": "testnamespace", // namespace name
	"subject": "campus/buildings/building17", // topic of the MQTT publish request. 
	"data": 
    {
		"Temp": 70,
		"humidity": 40
	}
}

針對已封入 CloudEventMQTT v5 訊息,無論是使用二進位 con 帳篷模式 還是 JSON 編碼中的結構化 con 帳篷模式,事件將會根據下列架構範例,使用原始預設 CloudEvents 屬性轉送事件。

{
	"specversion": "1.0",
	"id": "9aeb0fdf-c01e-0131-0922-9eb54906e20", // original id stamped by the client. 
	"time": "2019-11-18T15:13:39.4589254Z", // timestamp when the message was received by the client
	"type": "Custom.Type", // original type value stamped by the client.
	"source": "Custom.Source", // original source value stamped by the client.
	"subject": " Custom.Subject", // original subjectvalue stamped by the client.
	"data": 
    {
		"Temp": "70",
		"humidity": "40"
	}
}

後續步驟:

使用下列文章深入瞭解路由:

快速入門:

概念: