To get an email alert sent for any messaging failures (i.e., a failure in a send or receive port)
- For each send or receive port for which you want to track failures, edit the port properties and check the box for "Enable routing for failed messages"
- For send ports, you'll find this option under "Transport Advanced Options".
- The option for receive ports is under the General section of the port properties.
- Create a new Send Port (perhaps in a separate "Exception Handling" BizTalk application) that uses the SMTP adapter to send the emails.
- To send out all failed messages using this new port, create a filter on the send port with the Property
ErrorReport.ErrorType == FailedMessage
. That will evaluate as true for all messages that error on a send or receive port for which you enabled Failed Message Routing.
- If you need to route messages differently, at a more granular level, then have a look at the properties on the Failed Message Routing page referenced by ChrisLoris.
To track exceptions for failed messages in a separate database, I would start with the Microsoft BizTalk ESB Toolkit Exception Management Framework, as it includes a database for this purpose and the mechanism to push exception/failed message data into that database (build atop Failed Message Routing). It even includes a web site to enable users to interact with the failed messages, which you can customize as you see fit or throw away altogether.
The instructions to install the just the Exception Management part of the ESB Toolkit are available at http://msdn.microsoft.com/en-us/library/ee250099.aspx. Microsoft's guide to using the ESB Exception Management is worth a review too and is here.