简体   繁体   中英

How to identify if a private message queue (MSMQ) has exceeded its message storage limit using C#?

Is there a way using C# to identify whether a private MSMQ has exceeded it's storage limit (KB)?

In the following example I created a private MSMQ using the Computer Management console and I set the storage limit to 100 KB.

在此处输入图像描述

I send messages to the queue using a simple c# program which works fine. I would like to be able to figure out when the limit has been reached in order to stop sending messages.

MessageQueue msgQ =new MessageQueue(".\\Private$\\name_of_queue");
msgQ.Send(msg);

You should be able to use the MessageQueue.MaximumQueueSize Property to get the queue's maximum size.

The maximum size, in kilobytes, of the queue. The Message Queuing default specifies that no limit exists.

So, something like this should work:

var msgQ = new MessageQueue(".\\Private$\\name_of_queue");
long size = msgQ.MaximumQueueSize;

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