Creating a Loop within a Bridging Transaction

Many Bridging activities already process an entire dataset in one step—the bulk writers and manipulators iterate over every row of their input for you. A loop is what you build when you need to act on rows one at a time: to run a different branch per row, to call an activity that accepts only a single value, or to stop as soon as a condition is met.

A transaction diagram has no dedicated loop block. Instead, you combine three things you already have: a variable that holds the current position, a Condition activity that determines whether to continue, and a link that returns to that condition.

The following procedure uses a scenario in which a transaction reads the Orders table of the Northwind sample database installed with GENESIS and posts one audit event per order. Substitute your own reader and the activity you want to repeat.

To loop over the rows of a dataset:

  1. Open Workbench and in Project Explorer, expand your project > Bridging > Variables, right-click Local Variables, and select Add Static Variable.

    Using a local variable ensures that parallel instances of the transaction each keep their own counter.

  2. In the new variable configuration in Name, enter Counter, and in the Variable Dataset section, click Add a column to add a column named Integer.

  3. Select Click here to add new item to add a single row with the value 0, and then click Apply. Every instance of the transaction starts its counter at this value, so the loop needs no activity to initialize it.

  4. In Project Explorer under Bridging > Transactions, double-click the transaction to which you want to add the loop to open its configuration.

  5. In the Transaction Template section, click edit the transaction template to open the Template Designer, and use it to create the template diagram. Learn more

  6. When finished, click Apply. Then right-click the transaction in Project Explorer and select Test Transaction. The Transaction Log should show Log Order and Increment Counter executing once per row of the Orders dataset, in the order the rows were read, and the audit events server should hold one message per order.

A loop whose condition never becomes false runs until the transaction's Timeout expires. Always set a non-zero timeout on a transaction that contains a loop, and make sure the activity that changes the loop variable is on the path that repeats.

Keeping the Log Manageable

Every pass through a loop writes entries to the transaction log. On the Transaction Settings tab, Maximum activities logged limits the log to that many of the most recent activity entries, counting both retries and repeats in loops, so the log of a long-running loop does not grow without bound. Learn more

Looping Without a Diagram Loop

Before building a diagram loop, consider using the following alternatives if they apply to the task you are trying to achieve. Built-in bulk activity blocks are both simpler and faster.

  • Bulk Real Time Input

  • Bulk Real Time Output

  • Bulk Data Manipulator

  • Bulk Web Service Manipulator

  • Historical Upload

Each iterates over every row of an input dataset in a single activity, evaluating its expressions per row with {{column:<name>}}.