- In your orchestration, add a reference to Microsoft.Practices.ESB.ExceptionHandling and Microsoft.Practices.ESB.ExceptionHandling.Schemas.Faults (Open your project, Richt-Click on References à Add Reference à .Net)
- Create a Scope of Transaction Type ‘None’. You can also set the scope synchronization to true depending on your requirements. (This will suspend processing of the orchestration until the acknowledgement (Ack/Nack) has been received for the transmitted message)
- Add your operations for which you wish to catch the exception in this scope (make sure any messages to be used in the exception catching block are created outside this scope, though they can also be created within the scope if they must be, but some extra steps will be needed to initializie the message properly)
- On the Send port from which you wish to capture the delivery failure exception, in the properties, change the ‘Delivery Notification’ Type to ‘Transmitted
- Create orchestration Message called ‘msgESBFault’ of type Microsoft.Practices.ESB.ExceptionHandling.Schemas.Faults.FaultMessage
- Right-click on the scope and add a new Exception Handler
- In the Exception properties, Enter ‘DeliveryExceptionobjmsg’ as the Exception Object Name (or a name of your choosing)
- In the Exception properties, Select .Net Exception type Microsoft.XLANGs.BaseTypes.DeliveryFailureException as the Exception Object Type
- Add an Expression Shape called ‘WriteTraceLog’, a Construct Message Shape called ‘ConstructESBFaultmsg’ and a Send Shape called ‘SndESBFaultmsg’.
- Within the construct message shape, add a Message Assignment shape called ‘AssignESBFaultmsg’.
- Add a direct-bound Send Port ‘ESBFaultPort’ of Type ESBFaultPortType (See step 11 in earlier post Create a Soap Exception Catching Process from an Orchestration Request-Response Port using the ESB Portal)
- Add ‘Microsoft.Practices.ESB.ExceptionHandling.Schemas.Faults.FaultMessage’ as the Message Type of the direct-bound send port’s Operation
- In the Message Assignment shape, generate the ESB fault message and add your original message (from the actual scope) such as:
// create new fault message msgESBFault=Microsoft.Practices.ESB.ExceptionHandling.ExceptionMgmt.CreateFaultMessage();
// set fault message properties
msgESBFault.FaultCode="0202";
msgESBFault.FaultDescription="Delivery notification from port <portname> " + System.Environment.NewLine + "InnerXML is: " + DeliveryExceptionobjmsg.InnerException.ToString();
msgESBFault.FailureCategory="Delivery notification from port <portname>";
msgESBFault.FaultSeverity=Microsoft.Practices.ESB.ExceptionHandling.FaultSeverity.Severe;
//Add the fault message to the original message
Microsoft.Practices.ESB.ExceptionHandling.ExceptionMgmt.AddMessage(msgESBFault, msgFromOutsideScope); - Connect the send shape ‘SndESBFaultmsg’ to the direct send port
- In the Expression shape called ‘WriteTraceLog’, add the event log entry and debug helper messages such as: System.Diagnostics.Trace.WriteLine("Delivery notification from port <portname>");
After numerous years of thinking about it, I finally decided to start blogging the errors I documented in scribbles here and there over the years as and when I have the time, in the hope that they'll help some new 'BizTalk-er' to resolve their 'error-under-pressure' scenarios faster
Thursday, October 27
Create a Delivery Failure Exception Catching Process from an Orchestration Send Port using the ESB Portal
Note that, as explained in posts including this post by Kevin B Smith in 2004, the performance cost of using delivery notifications can be up to 50% depending on design. Therefore, for Request-Response ports, you can use the SOAP error handling capabilities instead of using delivery notification
Subscribe to:
Post Comments (Atom)
In step 3 you state that any messages you wish to use inside the catch block need to be create outside the scope and that additional steps are needed to if you want to create them inside the scope.
ReplyDeleteCan you outline describe the additional steps?