Iterator Usage Example

The following is a simplified example for iterator usage:

The message reaching the iterator is operated upon as appropriate, in this case simply duplicated, and then sent into the process flow, which performs an operation. Any service agents can be used in the loop, including iteration. When the message has been, as shown in the example, handled by the subflow, it is passed to another service which serves as the bottom of the loop. Any service can be the loop bottom, the preferrerd method is to use a move agent.

The OnComplete line or the OnSuccess line should be used between the end of loop (‘Loop back’). The next agent, the process flow interpreter, looks for these edges to route the end of an iteration message.

Upon reaching the end of the iteration, control is passed to the Do More agent and then to the end of the flow.

The iterator in our sample is configured for the number of iterations, instructions regarding what to pass on, and what to do at the end of the loop. While the iterator-specific configuration will vary, common configurations for iterators is the Output Document.

The Output Document instructs the iterator about what to pass to the end of loop, in this example, the service node called Do More. Some iterators offer additional choices, commonly available ones are:

Iterator

Description

Original

The document that first reached the iterator

Status

A status document describing the results of the iteration

An example of the Status Document is shown in the following image:

Configure the iterator at the start of loop, when a message arrives at the iterator. It cannot be reconfigured during the loop. In our example, a count might come from an XPath into the arriving message, but regardless of how that message changes, the count obtained at the start of the loop will be honored.

There are many available iterators, each performing a process and then passing the appropriate document into the loop or to the end of the loop. The most commonly used iterators are:

Iterator

Description

Count

Passes a document through the loop a configured number of times.

Condition

Evaluates an iFL expression as either a Do-While or Do-Until construction.

Attachments

Pass each attachment to the document (perhaps from an incoming HTTP or mail message) through the loop.

Line

Pass each line of a "text" input one at a time through the iterator. Lines end on terminator characters.

SQL Select

Each row from an SQL select operation is passed through the loop. The iterator can perform a batch update operation providing an Extract/Transform/Load operation within the flow.

Test

Similar to the test node in a flow and the condition iterator, it acts as a condition Do-While or Do-Until. It offers an extended range of comparisons such as "is empty" or "is equal ignore case".

XML Split

An incoming XML message is "split" on an XPath and each split portion is passed through the loop. It is commonly used to extract repeating elements from the incoming document such that each can be processed individually.


iWay Software