tags:

views:

259

answers:

1

Strange one. We have a multi-threaded app which pulls messages off a MSMQ Queue and then subsequently performs actions based on the messages. All of this is done using DTC.

Sometimes, for some reason I can't describe, we get message read errors when pulling Messages off the queue.

The code that is being used in the app:

Message[] allMessagesOnQueue = this.messageQueue.GetAllMessages();

foreach (Message currentMessage in allMessagesOnQueue)
{
    if ((currentMessage.Body is IAMessageIDealWith))
    {
       // do something;    
    }
}

When the currentMessage.Body is accessed, at times it throws an exception:

System.InvalidOperationException: Property Body was not retrieved when receiving the message. Ensure that the PropertyFilter is set correctly.

Now - this only happens some of the time - and it appears as though the MessageReadPropertyFilter on the queue has the Body property set to false.

As to how it gets like this is a bit of a mystery. The Body property is one of the defaults and we absolutley never explicitly set it to false.

Has anyone else seen this kind of behaivour or has some idea why this value is getting set to be false?

+1  A: 

I have seen it as well, and have tried initializing it with the properties I'm accessing explicitly set, and not setting them anywhere else. I periodically get the same error you are getting, my app is multi-threaded as well, what I ended up doing is trapping that error and reconnecting to MSMQ when I get it.