简体   繁体   中英

Monitoring an MSMQ queue

I've got an application that writes to a private MSMQ queue. I'd like to monitor whether the application is working properly by monitoring the queue. Normally I could just look at the number of messages on the queue using the performance counters but there is a very aggressive queue reader. If my monitoring program depends on seeing a message in the queue there is a good possibility that it will never see anything because messages have already been read before my monitoring application sees them. Ie I'm worried about the following timeline:

--+-W-R---W-R+--W-R--W-R+---WR-W--R+-W--R-W--R+---
where W is a write
      R is a read
      + is monitoring the queue

given the above, while there is activity (writes and reads) on the queue, there is never any activity when things are being monitored.

Is there any way to see the number of queue items that have passed through in the past minute or hour? Or anything else that might let me monitor the queue?

Your best bet is 1 of these 2 options:

  1. You can pause the queue via Windows shell to watch messages accumulate, and confirm it's working. This is of course a manual process, and I believe your monitor intention is automated. Works great for debugging however.
  2. You can have the queue producer and consumer each write the status for you as it does the work. In other words, every single time a producer creates a message, or a consumer processes a message, increment a count somewhere. Use these 2 counts to monitor (both should be going up and sum up to the same or close-to-same amount). You need to monitor both so that you know where the problem occurs, should it occur.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM