The Clone Mediator can be used to clone a message into several messages. It resembles the Scatter-Gather enterprise integration pattern and will copy the message into a number of identical messages that will be processed in parallel. The original message cloned can be continued or dropped depending on the Boolean value of the optional continueParent
attribute. Optionally, a custom To
address and/or an soapAction
may be specified for cloned messages. The Clone mediator is similar to the Iterate mediator, with the difference being that whereas the Clone mediator makes identical copies of the message, the Iterate mediator splits the message into multiple parts.
Syntax
<clone [continueParent=(true | false)]> <target [to="uri"] [soapAction="qname"] [sequence="sequence_ref"] [endpoint="endpoint_ref"]> <sequence> (mediator)+ </sequence>? <endpoint> endpoint </endpoint>? </target>+ </clone>
UI Configuration
The Clone Mediator Field Descriptions
- Clone ID - Identification of messages created by this clone mediator. This is particularly useful when aggregating responses of messages that are created using nested iterate mediators.
- Sequential Mediation
- Yes - Messages will be processed sequentially.
- No - Messages will be processed in parallel.
- Continue Parent
- Yes - The original message will be continued.
- No - The original message will be dropped.
- Number of clones - Number of clones created.
Tip
Number of clones can be controlled by adding one or more clone targets by clicking on the "Add Clone Target" link. Targets can then have their own sets of mediators.
The "Target Configuration" Window of the Mediator
Here, you can prepare a message to send to an endpoint or mediate through some more sequences.
- SOAP Action - The SOAP action of the message.
- To Address - The target endpoint address.
- Sequence - Mediate 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 - Send the message to an endpoint. Here you can pick a named endpoint from the registry or keep the endpoint as anonymous.
Note : If both Sequence and Endpoint defined, only sequence will be invoked and endpoint will be ignored.
Tip
You can add in the Endpoint panel that can be accessed from the Manage-> Mediation-> Endpoints menu in the left hand side menu bar.
Note
You can configure the Mediator using XML. Click on "switch to source view" in the "Mediator" window.
Example
<clone xmlns="http://ws.apache.org/ns/synapse"> <target> <endpoint name="endpoint_urn_uuid_73A47733EB1E6F30812921609540392-849227072"> <default /> </endpoint> </target> <target sequence="test1" /> </clone>
In this example, the Clone Mediator clones messages and redirects them to a Default Endpoint and an existing sequence.
See also Splitting Messages into Parts and Processing in Parallel (Iterate).