tags:

views:

923

answers:

1

This is a though on to explain, here i go.

We are creating a program where sender and receiver of the msmq is using WCF. We implemented a fault handle very similar as this: http://msdn.microsoft.com/en-us/library/ms751472.aspx in combination with http://msdn.microsoft.com/en-us/library/ms789028.aspx

Everything works great. We even made testcases which run 100's of messages through the queue and everything gets processed. When we make it 10000's we get some timeouts, but de error handling works fine so the message is retried a couple of times and then it ends up in the poison queue.

I checked in my code and released it to the other developers. The following problem occured more then one time while using the queue:

A message is not correctly read in ends up as a fault message (in the PoisonErrorHandler class). It always has this Exception message (of type FaultException): The message with To 'net.msmq://localhost/private/adpqueue' cannot be processed at the receiver, due to an AddressFilter mismatch at the EndpointDispatcher. Check that the sender and receiver's EndpointAddresses agree. In this error the Code.Name = Sender and Code.SubCode.Name = DestinationUnreachable

after the retry times it becomes a MsmqPoisonMessageException, it gets a LookupId. With this lookupid I do the ReceiveByLookupId(lookupId) (with the standard System.Messaging.MessageQueue class). This results in a InvalidOperationException.

After this the service will restart itself and the cycle will restart, this never ends. (after reboots, purging of the queue it never stops).

If you open Computer Management and look if there is a message on the queue it's empty. But when I open the p0000001.mq file (in the C:\WINDOWS\system32\msmq\storage) with a text editor you can see the message. If you delete this file, everything works again. I can't recreate the problem by using the application (I can recreate te problem becaue I saved a corrupt .mq file), it just occures sometimes.

This is not a workable situation. - Anyone any idea's how I can solve this problem through code or how to prevent it from happening? - Why is it that the wcf service can see the message, but the MessageQueue with LookupId sees nothing? - Is there another way to query the queue with a LookupId? - How can this situation occure? I can see all other messages.

+1  A: 

I finally found my problem.

On the receiving side of the queue I was using a nested transaction scope. When this happend: - Invalid message received - Exception - catch the exception - Dispose of the nested transaction

But the exception was thrown a little bit early, the nested transaction wasn't openend yet.

I think this infected the transaction of the transactional msmq and the message got locked and unreadable by the poisonhandle. When the service got restarted it could be read again, but got unreadable again because of the dispose of the nested transaction.

( to replay this behaviour in your receiving operation just type this: new TransactionScope(TransactionScopeOption.Required).Dispose(); )

Olivier