Click here to Skip to main content
6,630,901 members and growing! (20,272 online)
Email Password   helpLost your password?
Enterprise Systems » Microsoft BizTalk Server » General     Intermediate

A Quick guide to handling exceptions in BizTalk Orchestrations

By Naveen Karamchetti

This article explains the various scenarios in handling BizTalk exceptions
C#, Windows, .NET 1.1VS.NET2003, Dev
Posted:26 Mar 2006
Updated:19 Dec 2006
Views:53,391
Bookmarked:31 times
Unedited contribution
Announcements
Loading...
 
Search    
Advanced Search
Add to IE Search
printPrint   add Share
      Discuss Discuss   Broken Article?Report  
11 votes for this article.
Popularity: 4.13 Rating: 3.97 out of 5
2 votes, 18.2%
1

2
1 vote, 9.1%
3
2 votes, 18.2%
4
6 votes, 54.5%
5

Introduction

Most of us have might have written code to handle exceptions in any programming language. In BizTalk, exceptions are little bit different. This article explains how to handle exceptions and notification mechanism in ports, using some simple scenarios.

Exceptions vs Delivery Notification

The Delivery Notification flag on the Send Port indicates that the orchestration must be NOTIFIED back, in case the message has not been received by the destination. Delivery Notification works only when the Retry Count set to 0. When a message cannot be delivered, a DeliveryNotificationException is raised and the exception needs to be handled by the Orchestration.

Scenario 1 : Sending a Sales Report...

Consider a scenario where a sales report needs to be uploaded to a Web service.

Assumptions

  • If the Web service is not responding, it shall be online only after 24 hrs.
  • The retry count and interval on the Web Service Port is set to "0".

If the Web service is not responding, an exception is raised, and is handled by sending the message to an Offline folder.

SalesOrchestration




Receive shape - Receives a Sales Report message.
 
 
Scope shape - A scope defines a context in BizTalk. A scope is used to set a Transaction Type, in this case, the TransactionType is set to "None". The scope's Synchronized parameter is set to "true".
 
 
A Sales Report message is created, so as to tramit it to the web service.
WebPort
Note the properties of the Web Port which are marked in "Red".
 
Delivery Notification - If a message fails to be delivered on a Port, the "DeliveryFailureException" is generated. Note that "Delivery Notification" is NOT available for Binding property "Specify Now".
 
 
There are two kinds of Exceptions handled in this orchestration.
  • DeliveryFailure Exception
  • General Exception
 
General Exception - In this case, the message which needed to be sent to the Web Service, is written out to an Offline Folder.
 
Important Note: DeliveryFailure Exception - This exception is not thrown in this scenario, since a Web Service Port is request-response port. This is reason why the exception is handled in the General Exception section.

Event Log messages...

Observe the event log messages...

EvtLogSales

Scenario 2 : Raising the 'DeliveryFailureException' using a Dummy folder

In this scenario, we create a "Dummy" folder when messages need to be transmitted, and since the Dummy folder does not exist, we handle an exception and send the messages to the Offline folder.

NotificationOrchestration




Receive shape - Receives a Sales Report message.
 
 
 
A Sales Report message is created, so as to transmit it to the web service.
 
Scope shape - A scope defines a context in BizTalk. A scope is used to set a Transaction Type, in this case, the TransactionType is set to "None". The scope's Synchronized parameter is set to "true".
 
 
DummyPort
Note the properties of the ReportDummyPort which are marked in "Red".
 
Delivery Notification - If a message fails to be delivered on a Port, the "DeliveryFailureException" is generated. Note that "Delivery Notification" is NOT available for Binding property "Specify Now".
 
 
There are two kinds of Exceptions handled in this orchestration.
  • DeliveryFailure Exception
  • General Exception
 
A DeliveryFailure Exception is raised by the Port, since the file path specified in the Dummy Port does not exist. The exception handler handles the exception by sending the message into the OfflineFolder. Notice that in this case the DeliveryFailure Exception has been correctly raised.
 
 

Event Log messages...

Observe the event log messages...

EvtLogNotification

About the Downloadable Code

  • Unzip the Web Service with the folder names into the C:\inetput\wwwroot directory and setup the web service.
    NOTE - Rename the Persist.asmxto Persist2.asmx so as to make it unavailable.
  • Unzip the BizTalk project zip file with the folder names in the C:\ drive.
  • The folder KeyAndBindings contains the Bindings.xml file, which can be imported after the solution is built and deployed.
  • Place the SalesMessage in the In folder and check the Offline folder.

Some Takeaways

  1. Set the Synchronized property on the Scope shape to true, in the case you want to handle exceptions.
  2. Always select the "WebPortType" created when the "Web Reference" is added to the project, while creating "Web Ports" in the Orchestration.
  3. Delivery Notification is not available on Early Bound Ports.

DONT's miss the following references...

  1. Acknowledgments and Negative Acknowledgments (Part 1)
  2. BizTalk 2004 Delivery Notification and NACK Sample

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

Naveen Karamchetti


Member
Naveen Karamchetti has done his Masters (M.S.) in Software Engineering from B.I.T.S, Pilani and is based out of Fremont, CA.
The author has more than 8.5 yrs of experience in the IT industry, has started his career
starting from the good old days of using a Unix, Tcl/tk. The author has been associated with
several companies based out of Silicon Valley, California.

The author has won several programming awards within the organizations worked and is well-recognized. The author has also worked for Microsoft based at Redmond.

Hobbies include training, mentoring and research. Spends his free time travelling in the BART (Bay Area Rapid Transit) in Fremont, CA.
Occupation: Software Developer (Senior)
Location: United States United States

Other popular Microsoft BizTalk Server articles:

Article Top
You must Sign In to use this message board.
FAQ FAQ 
 
Noise Tolerance  Layout  Per page   
 Msgs 1 to 12 of 12 (Total in Forum: 12) (Refresh)FirstPrevNext
GeneralThanks for your articl . Tha't very excellent . Pinmemberxz_king19:50 27 Feb '08  
GeneralBeginner PinmemberAunalisiraj22:28 20 Jan '08  
Generalno change is Event Log. Pinmemberrajatpk10:17 15 Jan '07  
Generalwhy specify later PinmemberTareq Muhammad7:10 2 May '06  
AnswerRe: why specify later PinmemberNaveen Karamchetti20:31 2 May '06  
GeneralHow to Configure the Web port to start the Orchestration PinmemberKarthikcse1:43 10 Apr '06  
GeneralRe: How to Configure the Web port to start the Orchestration PinmemberNaveen Karamchetti4:23 10 Apr '06  
GeneralRe: How to Configure the Web port to start the Orchestration PinmemberKarthikcse4:30 10 Apr '06  
GeneralRe: How to Configure the Web port to start the Orchestration PinmemberNaveen Karamchetti5:20 10 Apr '06  
GeneralRe: How to Configure the Web port to start the Orchestration PinmemberKarthikcse19:38 10 Apr '06  
JokeRe: How to Configure the Web port to start the Orchestration PinmemberNaveen Karamchetti0:59 11 Apr '06  
GeneralRe: How to Configure the Web port to start the Orchestration PinmemberNaveen Karamchetti18:55 31 May '06  

General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

PermaLink | Privacy | Terms of Use
Last Updated: 19 Dec 2006
Editor:
Copyright 2006 by Naveen Karamchetti
Everything else Copyright © CodeProject, 1999-2009
Web19 | Advertise on the Code Project