簡體   English   中英

Azure IoT中心消息計數受消息大小影響嗎?

[英]Azure IoT Hub message count affectde by message size?

我試圖了解什么會影響Azure IoT中心消息計數器。

我正在從運行Windows IoT核心版的Raspberry Pi 3設備發送simplae JSON格式的消息。 郵件大小可能約為1kb。

我有一個簡單的函數,可以監視新消息並將它們到達時存儲在表存儲中。

每條消息都會使Azure IoT中心消息計數器增加大約10(而不是預期的1)

我沒有找到與此相關的任何信息-但是郵件大小會以某種方式影響郵件計數的方式嗎?

編輯

以下代碼示例僅使Azure中的消息計數器增加了4

using Microsoft.Azure.Devices.Client;
using System;
using System.Text;

namespace ConsoleApp1
{
    class Program
    {
        private static DeviceClient deviceClient;
        private static string iotHubUri = "iothubaccount.azure-devices.net";
        private static string deviceKey = "devicekey";

        private static string reading = @"{
cycle:0,
tempCentre:16.25,
trCentre:627,
tempCorner:16.00,
trCorner:619,
data: [
[{val: 643, convVal: 14.31, valA: 644}, {val: 1023, convVal: -94.70, valA: 1022}, {val: 628, convVal: 18.61, valA: 628}, {val: 620, convVal: 20.91, valA: 621}, {val: 622, convVal: 20.34, valA: 620}, {val: 621, convVal: 20.62, valA: 620}],
[{val: 645, convVal: 13.74, valA: 645}, {val: 1020, convVal: -93.84, valA: 1021}, {val: 630, convVal: 18.04, valA: 629}, {val: 620, convVal: 20.91, valA: 621}, {val: 620, convVal: 20.91, valA: 621}, {val: 621, convVal: 20.62, valA: 621}],
[{val: 644, convVal: 14.02, valA: 644}, {val: 1023, convVal: -94.70, valA: 1022}, {val: 627, convVal: 18.90, valA: 627}, {val: 620, convVal: 20.91, valA: 620}, {val: 621, convVal: 20.62, valA: 621}, {val: 620, convVal: 20.91, valA: 620}],
[{val: 667, convVal: 7.43, valA: 667}, {val: 1023, convVal: -94.70, valA: 1022}, {val: 733, convVal: -11.51, valA: 732}, {val: 644, convVal: 14.02, valA: 643}, {val: 645, convVal: 13.74, valA: 645}, {val: 644, convVal: 14.02, valA: 642}],
[{val: 644, convVal: 14.02, valA: 643}, {val: 1021, convVal: -94.13, valA: 1022}, {val: 628, convVal: 18.61, valA: 628}, {val: 619, convVal: 21.20, valA: 618}, {val: 619, convVal: 21.20, valA: 619}, {val: 618, convVal: 21.48, valA: 618}],
[{val: 665, convVal: 8.00, valA: 666}, {val: 1022, convVal: -94.42, valA: 1022}, {val: 648, convVal: 12.88, valA: 649}, {val: 644, convVal: 14.02, valA: 643}, {val: 644, convVal: 14.02, valA: 642}, {val: 643, convVal: 14.31, valA: 643}],
[{val: 1022, convVal: -94.42, valA: 1022}, {val: 1023, convVal: -94.70, valA: 1022}, {val: 1023, convVal: -94.70, valA: 1023}, {val: 1023, convVal: -94.70, valA: 1022}, {val: 1021, convVal: -94.13, valA: 1022}, {val: 1022, convVal: -94.42, valA: 1022}],
[{val: 651, convVal: 12.02, valA: 651}, {val: 1022, convVal: -94.42, valA: 1021}, {val: 654, convVal: 11.16, valA: 654}, {val: 627, convVal: 18.90, valA: 627}, {val: 628, convVal: 18.61, valA: 629}, {val: 629, convVal: 18.33, valA: 627}]
]}
";
        static void Main(string[] args)
        {
            Console.WriteLine("Sending message.");
            deviceClient = DeviceClient.Create(iotHubUri, new DeviceAuthenticationWithRegistrySymmetricKey("RegistredDeviceName", deviceKey), TransportType.Mqtt);
            var message = new Message(Encoding.ASCII.GetBytes(reading));
            deviceClient.SendEventAsync(message).Wait();
            Console.WriteLine("Message sent.");
            Console.ReadLine();
        }
    }
}

以下代碼示例僅使Azure中的消息計數器增加了4

如果您使用的是iot hub免費版,則是預期的。

根據您的代碼示例,您的消息有效負載長度為2027(字節)。 它將分為大約4個iot集線器消息(免費版的MESSAGE METER SIZE為0.5 KB )。

您可以使用message.BodyStream.Length獲得消息長度。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM