Logo
programming4us
programming4us
programming4us
programming4us
Home
programming4us
XP
programming4us
Windows Vista
programming4us
Windows 7
programming4us
Windows Azure
programming4us
Windows Server
programming4us
Windows Phone
 
Windows Server

BizTalk 2010 Recipes : Orchestrations - Using Nontransactional Orchestration Scopes

- Free product key for windows 10
- Free Product Key for Microsoft office 365
- Malwarebytes Premium 3.7.1 Serial Keys (LifeTime) 2019
4/14/2011 11:50:50 AM

1. Problem

You need to define how your orchestration behaves under possible exception conditions.

2. Solution

Any orchestration can have Scope shapes in it. Place other orchestration shapes within the Scope shape to define the expected behavior of the orchestration. If BizTalk encounters an exception performing the steps inside a Scope shape, it will jump to separate actions defined in an exception handler. The solution demonstrates how to add exception handling to an orchestration.

NOTE

A scope functions exactly like a traditional try/catch block.

  1. Create a new orchestration. Drag a Scope shape from the toolbox onto the orchestration design surface.

  2. Right-click the name of the Scope shape, and select Properties from the context menu.

  3. Set the Transaction Type property to None and the Name property to Controlled Exceptions Scope.

  4. Right-click the name of the new Scope shape, and select New Exception Handler from the context menu, as shown in Figure 1.

    Figure 1. Creating an exception handler
  5. Right-click the name of the exception handler created in the previous step, and select Properties Window from the context menu.

  6. Set the Exception Object Type property to General Exception and the Name property to Log Exception, as shown in Figure 2.

    Figure 5.46. Setting the Exception object type and name
  7. From the toolbox, drag an Expression shape into the exception handler.

  8. Double-click the Expression shape to open the Expression Editor, and add the following code to record the exception.

    System.Diagnostics.EventLog.WriteEntry("A Simple BizTalk Source",
    "An exception was encountered in my sample orchestration. ");

  9. Build the orchestration logic inside the Scope shape. If BizTalk encounters an exception processing the orchestration logic, it will invoke the Expression shape.

3. How It Works

The BizTalk Orchestration Designer is a development tool. Just as when building a component with any other development tool, exception conditions can occur long after the component is constructed. The developer may misunderstand how the component should behave, or changes to the other systems BizTalk interacts with may cause exception conditions. Regardless of the cause, the developer always needs to plan for the unexpected.

NOTE

In addition to defining how an orchestration reacts to possible exception conditions, orchestration scopes can also define atomic or long-running transactions.

This recipe demonstrates how to respond to exception conditions by invoking an Expression shape that writes an error message to the Windows application log. However, an exception handler can define more rigorous error-resolution procedures. The compensation block can simply log the exception, can invoke an exception-handling framework, or can invoke another BizTalk orchestration defining a series of resolution actions. In addition, if an orchestration defines the procedures for resolving exceptions, then the BizTalk Business Activity Monitor (BAM) can generate reports on exception-resolution processes.

3.1. Error Information

This solution's example uses the default General Exception object type, as shown earlier in Figure 2. This is useful when you want to log where and when errors occur but do not need specific information about the actual errors encountered.

An exception handler can identify more specific error information when the exception handler's Object Type property is set to any class inheriting from System.Exception. When the Object Type is a .NET Exception, as shown in Figure 3, the exception object can retrieve additional information such as an error message.

Modify the Expression shape as follows to include the error message in the application log entry.

System.Diagnostics.EventLog.WriteEntry("A Simple BizTalk Source",
"An exception was encountered: " + ex.Message);

Figure 3. Setting the exception handler type

3.2. Multiple Exception Handlers

A single Scope shape can also specify multiple exception handlers to define different reactions to different exceptions encountered by the orchestration. When the Scope shape encounters an exception, it will check each exception handler from top to bottom. The Scope shape invokes the first exception handler matching the type of exception encountered and stops looking for a match. Therefore, more specific exception handlers must appear above more general exception handlers, or the general exception handler will handle all errors and the Scope shape will never invoke the specific exception handlers. Define an additional exception handler with the following steps.

  1. Define the first exception handler as presented in this recipe's solution.

  2. Right-click the name of the Scope shape, and select New Exception Handler.

  3. Move the handler for the General Exception defined in the solution by selecting the name and dragging the mouse over the lower line defining the new exception handler. The General Exception handler should appear below the new one.

  4. Right-click the name of the new exception handler, and select Properties Window.

  5. Change the Name property to Handle Arithmetic Exception.

  6. For the Exception Object Type property, select <.NET Exception...>. In the Select Artifact Type dialog box that appears, select the Arithmetic Exception, as shown in Figure 4, and then click OK.

  7. Change the Exception Object Name property to ex.

  8. Add shapes to the new exception handler to handle arithmetic exceptions specifically, as shown in Figure 5.

Figure 4. Selecting the ArithmeticException

Figure 5. Defining arithmetic exception-specific shapes

While a Scope shape will invoke only the first exception handler matching the type of exception encountered, sometimes there are consistent actions the orchestration should take for different kinds of errors. For example, what if the orchestration depicted in Figure 5-49 should call the orchestration for resolving math errors in addition to logging the exception to the application log? The Throw shape can propagate an exception from the Scope shape that initially catches it to an outer Scope shape defining the consistent error actions. Figure 6 depicts an example of a Scope shape contained within another Scope shape.

NOTE

You can drag and drop the catch blocks from one exception block to another.

Figure 6. Nested scopes
Other -----------------
- BizTalk 2010 Recipes : Orchestrations - Using XPath Queries on Messages
- SharePoint 2010 : Working with the Other Standard Tools in a Document Library (part 4)
- SharePoint 2010 : Working with the Other Standard Tools in a Document Library (part 3)
- SharePoint 2010 : Working with the Other Standard Tools in a Document Library (part 2)
- SharePoint 2010 : Working with the Other Standard Tools in a Document Library (part 1)
- BizTalk 2010 Recipes : Orchestrations - Configuring Parallel Convoys
- BizTalk 2010 Recipes : Orchestrations - Maintaining Message Order
- Windows Server 2008 Server Core : Working with Performance Information (part 3)
- Windows Server 2008 Server Core : Working with Performance Information (part 2)
- Windows Server 2008 Server Core : Working with Performance Information (part 1) - Managing Performance Logs and Alerts with the LogMan Utility
 
 
Top 10
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 2) - Wireframes,Legends
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 1) - Swimlanes
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Formatting and sizing lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Adding shapes to lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Sizing containers
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 3) - The Other Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 2) - The Data Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 1) - The Format Properties of a Control
- Microsoft Access 2010 : Form Properties and Why Should You Use Them - Working with the Properties Window
- Microsoft Visio 2013 : Using the Organization Chart Wizard with new data
 
programming4us
Windows Vista
programming4us
Windows 7
programming4us
Windows Azure
programming4us
Windows Server