简体   繁体   中英

WCF MSMQ poison messages exception

I am writing a WCF service that has a transactional queue. 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.

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.

Another thing that you can do is to configure tracing by adding the following to your app.config to log any critical or error:

<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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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