WCF MSMQ binding. How to determine when a message has been moved to a poison queue?

I am running a WCF client that invokes a WCF service through MsmqBinding. Framework.Net 4.0, client and server running on Windows Server 2008 R2. The channel queue is transactional.

The service is hosted with these binding parameters: receiveErrorHandling="Move" receiveRetryCount="3" retryCycleDelay="00:00:20" maxRetryCycles="5"

Given that ((ReceiveRetryCount + 1) * (MaxRetryCycles + 1)) is valid, this will cause 4 * 6 = 24 repetitions of any given message until it is moved to the poisonous subarea.

Joining IErrorHandler to my service. I notice that HandleError is thrown with an MsmqPoisonMessageException exception a total of 6 times (for a poisonous message) before the wcf subsystem finally moves the message to the poison sublanguage.

I want to record the exact time when the message is running, and the message is moved to the poison queue. It seems to me that the only option is to count the number of errors of a particular message and compare this number with the MaxRetryCycles binding. This is inconvenient and erroneous.

My question is:

  • Is there a way for me to finally detect an event when the wcf subsystem moves a message to a poison queue?

My links: http://msdn.microsoft.com/en-us/library/aa395218.aspx

And: http://consultingblogs.emc.com/simonevans/archive/2007/09/17/A-comprehensive-guide-to-using-MsmqIntegrationBinding-with-MSMQ-3.0-in-WCF.aspx

+4
source share
2 answers

The number of attempts is, of course, the result of your parameters; however, in your IErrorHandler, you can explicitly move the message to the kernel queue yourself. Otherwise, it will always move through your binding parameters and will be detected when listening to the poison queue, as in any other queue.

+3
source

There are a number of good monitoring solutions that you can use to view message arrival queues. MonitorWang is an open source source that can detect when a message arrives in a poisonous message or error queue. Detecting when a message was received in the error queue is more reliable than trying to detect when a message was sent in the error queue.

+3
source

Source: https://habr.com/ru/post/1345214/


All Articles