BizTalk ESB Toolkit 2.0: Exception Management Gotchas–Create the Fault Message in the Right Place

I’ve been having a lot of fun lately with the ESB Toolkit. It’s got lots of great features, including Exception management which, by far, surpasses any framework that’s already out there. However, one small issue I’ve encountered is that when using the Exception Management framework, you must only create your message inside an Exception handler in your orchestration.

Code such as this:

FaultMsg = Microsoft.Practices.ESB.ExceptionHandling.ExceptionMgmt.CreateFaultMessage();

Anywhere besides inside an exception handler will cause your CPU to max out and your orchestration to hang indefinitely. On one occasion, I’ve seen the process complete, but that was when I started it on a Friday afternoon and left for the weekend to find it errored out on Monday morning. Other times, I’ve had to terminate the orchestration and then restart the host instance to clear it out and return my CPU to a less-stressed state.

I solved this issue by creating an exception object and throwing it when I hit a state in my orchestration that meant we shouldn’t go on anymore. If you want to send a fault message and just keep on going, I’m afraid you’re out of luck. One other caveat–you must use the generic System.Exception class when generating your custom exception to throw. If you don’t, the ESB framework will throw an exception similar to this:

Error 115004: An unexpected error occurred while attempting to retrieve the System.Exception object from the ESB Fault Message.

ADDENDUM (15 May 2012):  If you’d rather not use a work-around like that above, and if you’re willing to open up the ESB Toolkit source,  Daniel Probert has presented a solution here.

Advertisements

About Ed Jones

Ed is a Connected Systems and .NET Specialist for RBA in the Twin Cities. Contact Ed

Trackbacks / Pingbacks

  1. 2010 in review | Extremely Talented Monkeys - January 8, 2011
  2. BizTalk 2009 100% CPU | Biztalkslave's Blog - January 11, 2011

What do you think?

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: