受消息大小影响的 Azure IoT 中心消息计数?
Azure IoT Hub message count affectde by message size?
我正在尝试了解影响 Azure IoT 中心消息计数器的因素。
我正在从 Raspberry Pi 3 设备 运行 Windows IoT Core 发送一个简单的 JSON 格式的消息。邮件大小大概在1kb左右。
我有一个简单的函数,它监视新消息并在它们到达时将它们存储在 Table 存储中。
每条消息似乎都会使 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();
}
}
}
The follwoing code sample once has just bumped up the message counter
in Azure by 4
如果你使用iot hub免费版的话,可以期待。
根据您的代码示例,您的消息负载长度为 2027(字节)。这将被分成大约 4 个物联网中心消息(免费版 MESSAGE METER SIZE is 0.5 KB)。
您可以使用 message.BodyStream.Length
获取消息长度。
我正在尝试了解影响 Azure IoT 中心消息计数器的因素。
我正在从 Raspberry Pi 3 设备 运行 Windows IoT Core 发送一个简单的 JSON 格式的消息。邮件大小大概在1kb左右。
我有一个简单的函数,它监视新消息并在它们到达时将它们存储在 Table 存储中。
每条消息似乎都会使 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();
}
}
}
The follwoing code sample once has just bumped up the message counter in Azure by 4
如果你使用iot hub免费版的话,可以期待。
根据您的代码示例,您的消息负载长度为 2027(字节)。这将被分成大约 4 个物联网中心消息(免费版 MESSAGE METER SIZE is 0.5 KB)。
您可以使用 message.BodyStream.Length
获取消息长度。