The Iterate Mediator implements the Splitter and splits the message into a number of different messages derived from the parent message by finding matching elements for the XPath expression specified. New messages are 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 processed 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. The Iterate mediator is similar to the Clone mediator, with the difference being that the Iterate mediator splits a message into different parts, whereas the Clone mediator makes multiple identical copies of the message.
The responses will not necessarily be aggregated in the same order that the requests were sent, even if the
sequential attribute is set to
preservePayload attribute specifies if the original message should be used as a template when creating the split messages, and defaults to
false, in which case the split messages would contain the split elements as the SOAP body.
id attribute can be used to identify the iterator which created a particular split message when nested iterate mediators are used. This is particularly useful when aggregating responses of messages that are created using nested iterate mediators.
The Iterate Mediator can be configured with the following options:
- Iterate ID - Can be used to identify messages created by the iterate mediator. Useful when defining nested iterate mediators.
Sequential Mediation - Specifies whether split messages should be processed sequentially (True) or in parallel (False). If True is selected, you may experience a delay due to relatively high resource consumption. Therefore, it should be selected only when the order of the message is important. If False is selected, you may experience better performance. However, it is advisable to increase the size of the thread pool to enable the backend to handle the processing better. Default value is False (parallel processing).
- Continue Parent -Specifies whether the original message should be continued or dropped.
This is default to
- Preserve Payload -Specifies whether the original message should be used as a template when creating the split messages.
This is default to
- Iterate Expression - XPath expression that matches the elements, which you want to split the message from.
- Attach Path - To form new messages, you can specify an XPath expression for elements that the split elements are attached to (as expressed in Iterate expression).
You can click the "Namespaces" link to add namespaces if you are providing an expression. You will be provided another panel named "Namespace Editor," where you can provide any number of namespace prefixes and URL that you have used in the XPath expression.
Each Iterate Mediator has its own Target by Default
Here, you can prepare a message to be sent to an endpoint or mediated through some more sequences.
- SOAP Action - The SOAP action of the message.
- To Address - The target endpoint address.
- Sequence - Mediates the message through a sequence. You can either pick a named sequence from the registry or define an anonymous sequence by adding mediators to the current Target mediator as children.
Endpoint -Sends the message to an endpoint. Here you can pick a named endpoint from the registry or keep the endpoint as anonymous.
You can add in the Endpoint panel that can be accessed from the Manage-> Mediation-> Working with Endpoints menu in the left hand side menu bar.
You can configure the Mediator using XML. Click on "switch to source view" in the "Mediator" window.
In this scenario, the Iterate Mediator splits the messages into parts and processes them asynchronously. See also Splitting Messages into Parts and Processing in Parallel (Iterate/Aggregate).