使用Python获得Azure Service Bus的数量
我想知道我的队列中有太多的服务总线消息,如果需要重播(已丢失的消息)。我目前可以窥视和重播消息,但我对如何获得活动/死词计数不知道。 我基本上是在寻找相当于此PowerShell命令的Python。
az servicebus queue show --resource-group myresourcegroup \
--namespace-name mynamespace \
--name myqueue \
--query countDetails
有关于PowerShell的文档,但我找不到Python的任何东西。有人可以吗有人可以帮助我吗?
I want to know there are too many service bus messages in my queue and if need be replay(dead-lettered messages) them. I am currently able to peek and replay the messages but I have no clue on how to get the active/dead-lettered-message count.
I'm basically looking for the python equivalent of this powershell command.
az servicebus queue show --resource-group myresourcegroup \
--namespace-name mynamespace \
--name myqueue \
--query countDetails
There's documentation for this on powershell but I wasn't able to find anything for python. Can someone. Can someone kindly help me with this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用 azure服务总线python sdk 。
首先,使用get_queue方法获取队列的属性,该方法将包含称为message_count的属性,该属性将为您提供消息的计数。
You can use Azure Service Bus Python SDK.
First get the properties of a queue using get_queue method which will contain property called message_count which will give you the count of messages.
无法作为注释添加,其他答案是正确的WRT Azure服务总线Python SDK,但是代码略有不同的
示例代码:
关键部分是使用get_queue_runtime_properties,而不仅仅是get_queue
(可能是SDK自此更新的情况),
希望此帮助某人!
Can't add as a comment, other answer is correct wrt Azure Service Bus Python SDK however code is slightly different
Sample code:
Key part is using the get_queue_runtime_properties and not just get_queue
(May be the case that the SDK has updated since)
Hope this helps someone!