# Iterate Mediator

The iterate mediator implements an EIP (Enterprise Integration Pattern) -similar to the clone mediator and will split the message into number of different messages derived from the parent message by finding matching elements for the XPath expression specified. New messages will be created for each and every matching element and processed in parallel (default behavior) using either the specified sequence or endpoint. Created messages can also be set to process sequentially by setting the optional 'sequential' attribute to 'true'. The original message can be continued or dropped depending on the boolean value of the optional 'continueParent' attribute, in the same way as in the clone mediator. The 'preservePayload' attribute specifies if the original message should be used as a template when creating the splitted messages, and defaults to 'false', in which case the splitted messages would contain the split elements as the SOAP body. The optional 'id' attribute can be used to identify the iterator which created a particular splitted message when nested iterate mediators are used. This is particularly useful when aggregating responses of messages that are created using nested iterate mediators.

Figure1: Iterate Mediator

Iterate Mediator can be configured with the following options.

- Iterate ID: (Optional) This can be used to identify messages created by this iterate mediator, useful when nested iterate mediators are used.
- Sequential Mediation: (True/False), Specify whether splitted messages should be processed sequentially or in parallel. Default value is 'false' (parallel processing).
- Continue Parent: (True/False), Specify whether the original message should be continued or dropped, this is default to 'false'.
- Preserve Payload: (True/False), Specify whether the original message should be used as a template when creating the splitted messages or not, this is default to 'false'.
- Iterate Expression: Xpath expression that matches the elements which you want to split the message from. You can specify the namespaces that you used in the xpath expression by clicking the namespace link in the right hand side.
- Attach Path: (Optional), You can specify an xpath expression for elements that the splitted elements (as expressed in Iterate expression) are attached to, to form new messages