问题
Send() doesn't throw exception when the queue is full.
I have two private message queue, say queue and queue1, i set message storage of queue1 to a small amount say 5120 kb, in my program i send message to both queue and queue1, when queue1 is full while the global queue is not full, the Send() method on queue1 doesn't throw exception, why is this? i was expecting the send() method on queue1 throw exception so i know it is full.
回答1:
I think this is by design:
from MSMQ FAQ:
MQSendMessage() always succeeds even when it is obvious that the message cannot be sent. Why? The success of MQSendMessage() does not guarantee the delivery of the message to its ultimate destination. The success of MQSendMessage() merely means that the local MSMQ service successfully accepted the message and it will process it as soon as possible. It doesn't imply any guarantee to deliver the message to its destination queue. There are many reasons for failures to deliver a message. For example:
- You attempt to send a nontransactional message to a transaction queue.
- You send a message to a queue that has exceeded its quota.
- You send a message to a queue which does not grant you the send permission.
- You send a message to a computer which does not exist, using the DIRECT format name.
MQSendMessage() will succeed in all these cases, by design. It is the destination computer which reject such messages. Or the message will wait in an outgoing queue until it expires.
来源:https://stackoverflow.com/questions/19676882/message-queue-storage-limit-on-a-single-queue-doesnt-work