I want to look inside my queues, the msm console snapin has this property dialog, but it is very difficult to read and the messages which are important to me are encoded and loo
Try this:
string QueueName = @".\private$\publishingQueue";
//note, you cannot use method exists on remote queues
if (MessageQueue.Exists(QueueName))
{
var queue = new MessageQueue(queueInfo.QueueName)
{
MessageReadPropertyFilter = new MessagePropertyFilter
{
ArrivedTime = true,
Body = true
}
};
var messages = queue.GetAllMessages();
var m = messages[0];
m.Formatter = new System.Messaging.XmlMessageFormatter(new String[] {});
StreamReader sr = new StreamReader(m.BodyStream);
string ms = "";
string line;
while (sr.Peek() >= 0)
{
ms += sr.ReadLine();
}
//ms now contains the message
}