I'm trying to get a count of number of messages in a transactional queue on a clustered MSMQ, but for some reason this code:
static int GetMessageCount(MessageQueue q)
{
var filter = new MessagePropertyFilter()
{
AdministrationQueue = false,
ArrivedTime = false,
CorrelationId = false,
Priority = false,
ResponseQueue = false,
SentTime = false,
Body = false,
Label = false,
Id = false
};
q.MessageReadPropertyFilter = filter;
return q.GetAllMessages().Length;
}
With the queue path provided as:
FormatName:Direct=OS:cl-msmq\private$\t_Main.DroppedData
Give me a result of "0". If I check the queue it has 53 messages in queue. I've tried other variants of the path to the queue, but the one above is the only one NOT throwing an exception that it can't use the path.
Where am I going wrong here?
I'm able to send messages to that queue from the server in question, just not give a count. I've tried stepping through the queue using .Peek, message by message, but that also just give me "0" messages.
Maybe it's an RPC/permissions issue where you're not able to read the data from MSMQ (even though you can write to MSMQ as that doesn't use RPC). Would have expected an error, though. Is there code to swallow exceptions?