Click here to Skip to main content
15,888,323 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How do I get the name of the queues with only messages and how do I count the number of messages on each queues which has messages and how do I print message body in console application?

What I have tried:

C#
var q = MessageQueue.GetPrivateQueuesByMachine(machineName);


Now this will give me the list of all queues. but I need only those which has message and I need to count on each queues how many messages are there and message body.
Posted
Updated 4-May-16 19:57pm
v2

1 solution

MSDN help page provide comprehensive information on MessageQueue; you have all you need to solve your problem:
https://msdn.microsoft.com/en-us/library/system.messaging.messagequeue.getprivatequeuesbymachine%28v=vs.110%29.aspx[^],
MessageQueue Class (System.Messaging)[^],
MessageQueue.GetAllMessages Method (System.Messaging)[^].

Note the last link to the GetAllMessages function. It returns the message array, which you can use to see if there any messages. Just call the array's property Length.

It's not clear what you mean by "how many messages are there and message body"; this expression is not grammatically and logically correct. Anyway, get the message array and look at whatever you want.

—SA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900