简体   繁体   English

WCF MSMQ有毒消息异常

[英]WCF MSMQ poison messages exception

I am writing a WCF service that has a transactional queue. 我正在编写具有事务队列的WCF服务。 If the message processing continues failing it will be sent to the poison queue, and will be read by another service that is logging these failures. 如果消息处理继续失败,它将被发送到中毒队列,并将被记录这些失败的另一个服务读取。

The question is: how can I access the exception thrown that blocked the message processing? 问题是:如何访问抛出的异常以阻止消息处理?

The reason why your message ended up the poison queue is because an exception was thrown by your WCF service which was not caught. 您的消息最终进入中毒队列的原因是因为您的WCF服务引发了一个未捕获的异常。

So you can add a global exception handler in your WCF service and log this in the event viewer or log or whatever you prefer. 因此,您可以在WCF服务中添加一个全局异常处理程序,并将其记录在事件查看器或日志中,或使用您喜欢的任何内容。

Another thing that you can do is to configure tracing by adding the following to your app.config to log any critical or error: 您可以做的另一件事是配置跟踪,方法是将以下内容添加到app.config中以记录任何严重错误:

<system.diagnostics>
    <sources>
        <source name="System.ServiceModel" switchValue="Error, Critical" propagateActivity="true">
            <listeners>
                <add name="traceListener" type="System.Diagnostics.XmlWriterTraceListener" initializeData="c:\traces.svclog" />
            </listeners>
        </source>
    </sources>
</system.diagnostics>

Have a look at the receiveErrorHandling options what you can do whenever your WCF encounters an uncaught exception. 看一下receiveErrorHandling选项 ,当WCF遇到未捕获的异常时可以执行的操作。

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

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