简体   繁体   English

WCF超过MSMQ绑定。如何检测邮件何时移动到毒性队列?

[英]WCF over MSMQ binding. How do I detect when a message is moved to the poison queue?

I am running a WCF client that invokes a WCF service via an MsmqBinding. 我正在运行一个WCF客户端,它通过MsmqBinding调用WCF服务。 Framework is .Net 4.0, client and server runs on Windows Server 2008 R2. 框架是.Net 4.0,客户端和服务器在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" 该服务由以下绑定参数托管: receiveErrorHandling="Move" receiveRetryCount="3" retryCycleDelay="00:00:20" maxRetryCycles="5"

Given that ((ReceiveRetryCount+1) * (MaxRetryCycles + 1)) is in effect, this will result in 4*6 = 24 retries of any given message before it is moved to the poison subqueue. 鉴于((ReceiveRetryCount + 1)*(MaxRetryCycles + 1))生效,这将导致任何给定消息的4 * 6 = 24次重试,然后将其移至毒性子队列。

Attaching an IErrorHandler to my service I notice that HandleError is called with a MsmqPoisonMessageException a total of 6 times (for a poison message), before the wcf subsystem finally moves the message to the ;poison subqueue. 将IErrorHandler附加到我的服务我注意到在wcf子系统最终将消息移动到; poison subqueue之前,调用HandleError时,MsmqPoisonMessageException共计6次(对于有毒消息)。

I want to log the precise time when a message is done being retried and the message is moved to the poison queue. 我想记录重试消息的准确时间,并将消息移动到毒性队列。 It seems to me the only option is to count the number of times a certain message faults and compare this count with the binding MaxRetryCycles. 在我看来,唯一的选择是计算某个消息出错的次数,并将此计数与绑定MaxRetryCycles进行比较。 This is awkward and errorprone. 这是尴尬和错误。

My question is: 我的问题是:

  • Is there any way for me to conclusively detect the event where the wcf subsystem moves the message to the poison queue? 有没有办法让我最终检测到wcf子系统将消息移动到毒性队列的事件?

My references are: http://msdn.microsoft.com/en-us/library/aa395218.aspx 我的参考资料是: 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 并且: http//consultingblogs.emc.com/simonevans/archive/2007/09/17/A-comprehensive-guide-to-using-MsmqIntegrationBinding-with-MSMQ-3.0-in-WCF.aspx

The number of retries is of course an outcome of your parameters; 重试次数当然是您参数的结果; however in your IErrorHandler you can explicitly move the message to the poison queue yourself. 但是在IErrorHandler中,您可以自己将消息显式移动到毒性队列。 Otherwise, it will always move based on your binding parameters, and would be detected by listening to the poison queue like any other queue. 否则,它将始终根据您的绑定参数移动,并通过像任何其他队列一样侦听毒性队列来检测。

There are a number of good monitoring solutions that you can use to watch message queues for the arrival of a message. 您可以使用许多良好的监控解决方案来查看消息到达的消息队列。 MonitorWang is an open source one that can detect when a message has arrived in a poison message or error queue. MonitorWang是一个开源的,可以检测消息何时到达有害消息或错误队列。 Detecting when a message has been received in the error queue is more reliable than trying to detect when a message has been sent to the error queue. 检测错误队列中何时收到消息比检测消息何时发送到错误队列更可靠。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM