Tuesday, June 03, 2008

BizTalk Exception Management

The latest publication of BizTalk Hotrod Magazine is available and can be downloaded. The topics in this issue covered are:

• BizTalk Exception Management
• Exposing Business Rules Engine Policies as WCF Services
• Tools of the Trade
• Parallel Convoys in BizTalk
• A Glimpse of the BizTalk Server 2006 R2 WCF Adapters
• Smart Use of XSLT BizTalk
• In the beginning
• What's Under that Hood?

I have read this edition and found the BizTalk Exception Management Application is a great article. It walks you through an enterprise BizTalk Exception Management application based upon the Patterns and Practices ESB Exception Management Framework. If you have ever thought about using the ESB Exception Management Framework, this article serves as a great primer.

So I started experimenting with this Framework, not in a BizTalk 2006 R2 environment, but just BizTalk Server 2006. In my environment I had Microsoft Windows 2003 Standard Edition SP2 OS, 1,6Ghz processor and 512 Mb of RAM. It had Office, Visual Studio 2005 and SQL Server 2005 installed. Here I download Patterns and Practices ESB Guidance 1.0 November 2007. Then I took one of the examples from the SDK like HelloWorld orchestration (\\Program Files\Microsoft BizTalk Server 2006\SDK\Samples\Orchestrations\HelloWorld) and added scope and exception.













I wanted to find out how to publish the message simply to file as an experiment.

Code inside assign values shape:
//Construct a new Fault Message
FaultMessage = Microsoft.Practices.ESB.ExceptionHandling.ExceptionMgmt.CreateFaultMessage();
//Assign values
//FaultMessage(Microsoft.Practices.ESB.ExceptionHandling.Schemas.Property.Application)= "HelloWorld";
FaultMessage.FailureCategory = "MessageBuild";
FaultMessage.FaultCode = "NNNN";
FaultMessage.FaultDescription = "Some error occured";
FaultMessage.FaultSeverity = Microsoft.Practices.ESB.ExceptionHandling.FaultSeverity.Severe;
FaultMessage.Scope = "Execution Scope";
//Add suspended message (SourceMessage) to the FaultMessage
Microsoft.Practices.ESB.ExceptionHandling.ExceptionMgmt.AddMessage(FaultMessage,POMessage);
//Add the exception from the exception handler to the FaultMessage
Microsoft.Practices.ESB.ExceptionHandling.ExceptionMgmt.SetException(FaultMessage,ex);


To create an error inside the orchestration I created two variables and let a divide by zero error occur:

//Generate divide by zero exception
y=0;
x = 1/y;

When I tested it it finally resulted in a message inside a folder. Message looked like this.





Well that worked, so I am going to look into it some more. ESB Guidance package is intended for BizTalk Server 2006 R2, but Exception Management part can be implemented in BizTalk Server 2006 enviroment.

Technorati:

No comments: