繁体   English   中英

在Azure存储队列中明确添加批处理消息

[英]Explicitly adding batch messages in Azure storage queue

我正在使用Azure函数V1将10,000条消息添加到我的存储队列中。

我正在做一个循环。它不是实时场景,但我想一次检查它(队列)是否支持那么多消息。 所以是批量插入。

现在,它正在添加随机数的消息,例如998或77或246。我将使用队列触发器通过稍后手动运行该触发器来对消息进行排队。

我有一个天蓝色的免费订阅帐户。

以下是我为添加消息而编写的代码。

CloudQueueMessage message = new CloudQueueMessage('4547');
var queue = GetQueue();//getqueue function is creating the queue.
Dictionary<string, int> dic = new Dictionary<string, int>();

for (int i = 1; i < 10001; i++) {
    queue.AddMessageAsync(message).Wait();
}

默认情况下,门户中仅显示32条消息。我通过以下代码获取消息数。

queue.FetchAttributes();
dic.Add(queue.Name, queue.ApproximateMessageCount.HasValue ? queue.ApproximateMessageCount.Value : -1);

该函数显示它已成功执行,但未在其中添加所有消息

队列。 删除Wait()可以解决问题,并且现在添加了所有消息。

谢谢。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM