مخطط الحدث للرسائل التي تم توجيهها إلى MQTT
يتم توجيه رسائل MQTT إلى موضوع Event Grid ك CloudEvents وفقا للمنطق التالي:
بالنسبة لرسائل MQTT v3 أو رسائل MQTT v5 لمؤشر تنسيق الحمولة =0، ستتم إعادة توجيه الحمولة في الكائن data_base64 وترميزها كسلسلة 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==
}
}
بالنسبة لرسائل MQTT v5 من نوع المحتوى= "application/json; charset=utf-8" أو مؤشر تنسيق الحمولة =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
}
}
بالنسبة لرسائل MQTT v5 المغلفة بالفعل في CloudEvent وفقا لربط بروتوكول MQTT ل CloudEvents سواء باستخدام con ثنائي وضع الخيمة أو con المنظم وضع الخيمة في ترميز JSON (utf-8)، ستتم إعادة توجيه الحدث مع سمات 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"
}
}
الخطوات التالية:
استخدم المقالات التالية لمعرفة المزيد حول التوجيه:
Quickstart:
- البرنامج التعليمي: توجيه رسائل MQTT إلى مراكز أحداث Azure باستخدام مواضيع مساحة الاسم
- البرنامج التعليمي: توجيه رسائل MQTT إلى Azure Functions باستخدام مواضيع مخصصة
Concepts:
- التوجيه
- تصفية التوجيه
- إثراء التوجيه