簡體   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