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
  1. 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)
  2. 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)
  3. 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)
  4. On the Send port from which you wish to capture the delivery failure exception, in the properties, change the ‘Delivery Notification’ Type to ‘Transmitted
  5. Create orchestration Message called ‘msgESBFault’ of type Microsoft.Practices.ESB.ExceptionHandling.Schemas.Faults.FaultMessage
  6. Right-click on the scope and add a new Exception Handler
  7. In the Exception properties, Enter ‘DeliveryExceptionobjmsg’ as the Exception Object Name (or a name of your choosing)
  8. In the Exception properties, Select .Net Exception type Microsoft.XLANGs.BaseTypes.DeliveryFailureException as the Exception Object Type
  9. Add an Expression Shape called ‘WriteTraceLog’, a Construct Message Shape called ‘ConstructESBFaultmsg’ and a Send Shape called ‘SndESBFaultmsg’.
  10. Within the construct message shape, add a Message Assignment shape called ‘AssignESBFaultmsg’.
  11. 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)
  12. Add ‘Microsoft.Practices.ESB.ExceptionHandling.Schemas.Faults.FaultMessage’ as the Message Type of the direct-bound send port’s Operation
  13. 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);
  14. Connect the send shape ‘SndESBFaultmsg’ to the direct send port
  15. 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>");

1 comment:

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

    Can you outline describe the additional steps?

    ReplyDelete