[英]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
,它为您提供具有成员MessageCount
的QueueRuntimeInfo
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.