2
votes

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?

1

1 Answers

1
votes

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.