Azure IoT Hub消息计数是否按消息大小影响?

时间:2017-07-23 20:11:51

标签: azure windows-10-iot-core azure-iot-hub

我试图了解影响Azure IoT Hub消息计数器的因素。

我从运行Windows IoT Core的Raspberry Pi 3设备发送简单的JSON格式消息。邮件大小可能大约为1kb。

我有一个简单的函数,可以监视新消息并在它们到达时将它们存储在表存储中。

每条消息都会将Azure IoT Hub消息计数器增加大约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();
        }
    }
}

1 个答案:

答案 0 :(得分:1)

  

下面的代码示例刚刚碰到了消息计数器   在Azure中由4

预计如果您使用iot hub免费版。

根据您的代码示例,您的消息有效负载长度为2027(字节)。这将被分为大约4个iot集线器消息(免费版MESSAGE METER SIZE is 0.5 KB)。

您可以使用message.BodyStream.Length获取邮件长度。