简体   繁体   English

使用 Microsoft.Azure.Management.ServiceBus 获取队列消息计数

[英]Get queue message count using Microsoft.Azure.Management.ServiceBus

I need an example on how to make CRUD operations on service bus queues.我需要一个关于如何对服务总线队列进行 CRUD 操作的示例。

I actually need an instance of Microsoft.Azure.Management.ServiceBus.SBQueue class, so I can count the messages in that queue.我实际上需要一个 Microsoft.Azure.Management.ServiceBus.SBQueue 类的实例,以便我可以计算该队列中的消息数。

Use the ManagementClient to call GetQueuesRuntimeInfoAsync , which gives you the QueueRuntimeInfo which has a member MessageCount使用ManagementClient调用GetQueuesRuntimeInfoAsync ,它为您提供具有成员MessageCountQueueRuntimeInfo

var managementClient = new ManagementClient(connectionString);
var queueRuntimeInfo = await managementClient.GetQueueRuntimeInfoAsync(queueName);
Console.WriteLine(queueRuntimeInfo.MessageCount);

Use ServiceBusAdministrationClient()使用 ServiceBusAdministrationClient()

var client = new ServiceBusAdministrationClient(_connectionString);
QueueRuntimeProperties queue = await client.GetQueueRuntimePropertiesAsync(queueName);
int count = (int)queue.ActiveMessageCount;

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

相关问题 Azure Servicebus队列消息处理 - Azure servicebus queue message handling Microsoft.Azure.ServiceBus 如何获取消息 State - Microsoft.Azure.ServiceBus How to get Message State 使用 SignalR 从 Azure ServiceBus 消息队列向 Azure Web 应用广播数据 - Using SignalR to broadcast data to Azure Web App from Azure ServiceBus Message Queue 在Azure函数中使用BrokeredMessage和ServiceBus队列触发器 - Using BrokeredMessage with ServiceBus Queue Trigger in Azure Function 无法加载文件或程序集“Microsoft.Azure.Management.ServiceBus.Fluent” - Could not load file or assembly 'Microsoft.Azure.Management.ServiceBus.Fluent' Microsoft.Azure.ServiceBus:提供的锁无效。 锁已过期,或消息已从队列中删除 - Microsoft.Azure.ServiceBus: The lock supplied is invalid. Either the lock expired, or the message has already been removed from the queue Microsoft对Azure Webjob Service的Microsoft.Azure.ServiceBus.Message支持 - Microsoft.Azure.ServiceBus.Message support for Azure Webjob Service 无法从 Azure 获取队列长度/消息计数 - Unable to get queue length / message count from Azure 使用 Azure.Messaging.ServiceBus.Administration 创建 ServiceBus 队列时出错 - Error when creating ServiceBus Queue using Azure.Messaging.ServiceBus.Administration 如何使用 Microsoft.Azure.ServiceBus 在订阅上创建 MessageReceiver - How to create MessageReceiver on subscription using Microsoft.Azure.ServiceBus
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM