c# - Azure 存储队列是否没有新消息到达事件?

标签 c# azure

一直在寻找类似于 Azure 服务总线队列的工具,其中消息传递泵用于在新消息到达时触发 OnMessage(BrokeredMessage msg)。

Does Azure Storage Queue, not have such event supported?

// Retrieve storage account from connection string
CloudStorageAccount storageAccount = CloudStorageAccount.Parse(
    CloudConfigurationManager.GetSetting("StorageConnectionString"));

// Create the queue client
CloudQueueClient queueClient = storageAccount.CreateCloudQueueClient();

// Retrieve a reference to a queue
CloudQueue queue = queueClient.GetQueueReference("myqueue");

// Get the next message
CloudQueueMessage retrievedMessage = queue.GetMessage();

//Process the message in less than 30 seconds, and then delete the message
queue.DeleteMessage(retrievedMessage);

最佳答案

Azure 存储队列本身不支持此功能。客户端需要轮询队列以检查该队列中是否有新消息。

您可以使用函数或 WebJobs 触发器来模拟基于事件的行为。然而,每当他们在队列中发现消息时,他们就会在内部轮询队列并调用函数/webjob(或者换句话说引发事件)。

关于c# - Azure 存储队列是否没有新消息到达事件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49858181/

相关文章:

c# - 您如何确定使用哪个适配器?

c# - 使用 BsonClassMap 时获取 MongoDB 中插入文档的 _id?

c# - 替换字符串中的多个字符,最快的方法是什么?

c# - 有没有一种方法可以将 DataRow 映射到类的对象

azure - 安装 Azure SDK 1.8 时,云模板不会安装在 VS2012 中

Azure Rest Api 列表容器 : Parameter Marker

azure - Power Bi 嵌入式部署

c# - C# 中类型参数的“词法”范围

azure - 访问 Microsoft Graph API : Resource app ID: 00000002-0000-0000-c000-000000000000

Azure Bicep 不会删除存储容器