Handling Exception in BizTalk

{tocify} $title={Table of Contents}

Introduction


In BizTalk we have two ways of defining a solution, one is messaging solution and the orchestration based solution.

Exceptions are the events in which some expected or unexpected scenarios takes place which are not the happy path(normal flow).

While we design solution, some of the exceptions can be identified(known events which we are aware of) but some events can't be identified.

Thus the approach should be  to include exception handling mechanism/process to first address specific exception event and then finally to add process to handle events the which are not known.

Exception handling in BizTalk in two categories 
1. Handling exception on port level
2. Handling exception in orchestration 

Handling exception on port level


Whenever there is a failure or some exception in the messaging solution the messages gets suspended and whatever message gets failed, all the promoted properties are demoted and error properties are populated.

BizTalk creates a clone of  that particular failed message  where properties related to error are populated and promoted.

Which are made available and can be used to create exception handling process like for example you can route the failed messages to a folder by subscribing to this error related property

Few of the properties which are available are

  • ErrorReport.Description
  • ErrorReport.ErrorType
  • ErrorReport.FailureCode
  • ErrorReport.FailureType
  • ErrorReport.FailureCategory
  • ErrorReport.FailureInstanceID
  • ErrorReport.FailureMessageID
  • ErrorReport.Failuretime
  • ErrorReport.MessageType
  • ErrorReport.ReceivePortName
  • ErrorReport.InboundTransportLocation
  • ErrorReport.SendPortName
  • ErrorReport.OutboundTransportLocation
  • ErrorReport.RoutingFailureReportID
  • ErrorReport.ProcessingServer



Handling exception in orchestration


For handling exception in BizTalk orchestration, scope (None or Long Running) shape is  to be added associating it with Exception Handling Block :

1. We first define the Exception Object Type in the properties tab of Exception Block.

2. If your intention is to handle specific exception (suppose, you want to handle SOAP exception) then select that type and also give a name to that object.

3. This object  holds the error information when exception occurs.

4. You can use the Message Assignment shape and assign this object to the message you want to send.

e.g, i. You have named your object as soapExceptionObject

      ii. You want to send fault_message after an exception occurs

     iii. Assign fault_message = soapexceptionObject; in Message assignment shape

4. For general exception set Exception Object Type to General Exception.

5. Here you don't have the privilege of naming the exception object.

General Exception in BizTalk is similar to a try-catch block but it does not have the exception object, so it's not possible to get the exception object.

It allows  to deal with any exception (being generic in nature- for all exceptions) it may catch and re-throw, but you can't get the exception message at that point.

You can have your own mechanism built to send a customized message to the user but unfortunately not the exact exception message.

If you have questions or suggestions, feel free to do in comments section below !!!


Do share if you find this helpful .......
 
                          Knowledge Sharing is Caring !!!!!!



Related Post 





Post a Comment

If you have any suggestions or questions or want to share something then please drop a comment

Previous Post Next Post