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 the Loop Shape

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

1. Problem

You need to repeat a series of steps in an orchestration until a certain condition is met.

2. Solution

You can use the Loop shape in a BizTalk orchestration, in a manner similar to using a loop in any programming language, such as this looping logic:

int a = 0;
while(a < 3)
{
System.Console.WriteLine(a);
a = a + 1;
}

As an example, the following steps show how to implement a loop that terminates after a counter variable has been incremented to a certain value. The orchestration will loop three times, logging its progress to the Windows Event Viewer.

NOTE

The example demonstrates a complete orchestration that could be called from another orchestration using the Call or Start Orchestration shape. To make this a stand-alone orchestration, simply add a Receive shape as the first step and bind it to a port.

  1. In an empty orchestration, create a new variable called intCount. Make it of type Int32. This will represent the loop counter.

  2. Drop an Expression shape on the design surface. Rename this shape to Set_Count. Then double-click the shape, and type in the following code:

    //initialize counter
    intCount = 0;

  3. Drop a Loop shape below the Set_Count shape. Double-click the Loop shape, and enter the following code (note there is no semicolon):

    //loop while count is less than 3

    intCount < 3

  4. Drop another Expression shape inside the Loop shape, and rename it Increase_Count. Enter the following code:

    //increase counter
    intCount = intCount + 1;
    //log to the event viewer
    System.Diagnostics.EventLog.WriteEntry("Count",
    System.Convert.ToString(intCount));

The orchestration is shown in Figure 1.

Figure 1. Loop shape with counter

3. How It Works

The Loop shape has many applications, from looping through XML documents to supplementing the Listen shape, exception handling routines, and so on. Orchestrations can mimic the behavior of long-running Windows services with the proper placement of a Loop shape. For example, if you need to poll for data on a timed interval, you could set up an orchestration to do this. An initial Receive shape would instantiate the orchestration and immediately enter a loop. Once in the loop, it would never exit, looping every [x] number of minutes to reexecute a series of steps. The orchestration would be long-running and would never end until terminated manually. An example of this type of orchestration is shown in Figure 2.

Figure 2. Long-running polling orchestration
Other -----------------
- BizTalk 2010 Recipes : Orchestrations - Using the Parallel Action Shape
- BizTalk 2010 Recipes : Orchestrations - Receiving Untyped Messages
- Windows Server 2008 R2 : File System Management and Fault Tolerance - Using the Volume Shadow Copy Service
- Windows Server 2008 R2 : File System Management and Fault Tolerance - Backing Up DFS
- Windows Server 2008 R2 : File System Management and Fault Tolerance - Managing and Troubleshooting DFS
- SharePoint 2010 PerformancePoint Services : SharePoint 2010 Filters
- SharePoint 2010 PerformancePoint Services : PPS Filters
- Feature Comparison Between SharePoint Foundation 2010 and SharePoint Server 2010 for Farm Administrators (part 3)
- Feature Comparison Between SharePoint Foundation 2010 and SharePoint Server 2010 for Farm Administrators (part 2)
- Feature Comparison Between SharePoint Foundation 2010 and SharePoint Server 2010 for Farm Administrators (part 1)
 
 
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