检查输入队列中的消息数队列、消息

2023-09-06 17:38:52 作者:滿腔熱血.

这是可能获得使用NServiceBus我InputQueue内部消息的数量,而且我需要绕过它,并使用本地MSMQ接口?

Is this possible to get the number of messages inside my InputQueue using NServiceBus and do I need to bypass it and use native MSMQ interface?

它不会是一个完整的监控,我们已经得到了包括若干NSB组件的系统,他们正在通过Windows性能计数器的使用情况进行监控。我正在努力实现仅仅是一个简单的健康检查 - >发送NSB消息一个组成部分,它的反应是遏制假设DB访问状态,并在其队列MSMQ消息的数量。 这就是为什么我想使它尽可能简单。所以,问题是:我可以检查以简单的方式在消息编号或者我宁愿需要读取性能计数器

It's not gonna be a complete monitoring, we've got a system comprising several NSB components and they're monitored through the usage of Windows performance counters. What I'm trying to achieve is just a simple health check -> sending a NSB message to a component, its response is to contain let's say DB access status and number of MSMQ messages in its queue. That's why I'd like to make it as simple as possible. So the question is: can I check the message number in a simple way or I'd rather need to read the performance counter ?

推荐答案

您不得不使用System.Messaging.MessageQueue.GetAllMessages()或它的枚举的方法之一来获得这些信息。 NServiceBus不公开这一点。

You'd have to use the System.Messaging.MessageQueue.GetAllMessages() or one of its enumerator methods to get that information. NServiceBus doesn't expose this.