The Aggregate mediator implements the Aggregator and aggregates the response messages for messages that were split by the Clone or Iterate mediator and sent using the Send mediator. Note that the responses will not necessarily be aggregated in the same order that the requests were sent, even if you set the
sequential attribute to
true on the Iterate mediator.
The parameters available for configuring the Aggregate mediator are as follows.
|Aggregate ID||This optional attribute can be used to aggregate only responses for split messages that are created by a specific clone/iterate mediator. Aggregate ID should be the same as the ID of the corresponding clone/iterate mediator that creates split messages. This is particularly useful when aggregating responses for messages that are created using nested clone/iterate mediators.|
|Aggregation Expression||An XPath expression specifying which elements should be aggregated. A set of messages that are selected for aggregation is determined by the value specified in the Correlation Expression parameter.|
|Completion Timeout||The number of seconds taken by the Aggregate mediator to wait for messages. When this time duration elapses, the aggregation will be completed. If the number of response messages reaches the number specified in the Completion Max-messages parameter, the aggregation will be completed even if the time duration specified for the Completion Timeout parameter has not elapsed.|
|Completion Max-messages||Maximum number of messages that can exist in an aggregation. When the number of response messages received reaches this number, the aggregation will be completed.|
|Completion Min-messages||Minimum number of messages required for the aggregation to complete. When the time duration entered in the Completion Timeout parameter is elapsed, the aggregation will be completed even if the number of minimum response messages specified has not been received. If no value is entered in the Completion Timeout parameter, the aggregation will not be completed until the number of response messages entered in the Completion Min-messages parameter is received.|
This is an XPath expression which provides the basis on which response messages should be selected for aggregation. This is done by specifying a set of elements for which the messages selected should have matching values. A specific aggregation condition is set via the Aggregation Expression parameter.
You can click NameSpaces to add namespaces if you are providing an expression. Then the Namespace Editor panel would appear where you can provide any number of namespace prefixes and URLs used in the XPath expression.
|Enclosing Element Property||This parameter is used to accumulate the aggregated messages inside a single property. The name of the relevant property is entered in this parameter.|
The sequence to run when the aggregation is complete. You can select one of the following options:
You can configure the mediator using XML. Click switch to source view in the Mediator window.
Example 1 - Sending aggregated messages through the send mediator
In this example, the mediator aggregates the responses coming into the ESB, and on completion it sends the aggregated message through the Send mediator.
Example - 2 Sending aggregated messages with the enclosing element
The following example shows how to configure the Aggregate mediator to annotate the responses sent from multiple backends before forwarding them to the client.
The above configuration includes the following:
<property name="info" scope="default"> <ns:Information xmlns:ns="www.asankatechtalks.com" /> </property>
|This creates the property named |
|The ID of the corresponding Clone mediator that splits the messages to be aggregated by the Aggregate mediator.|
|This expression is used to add the |
|This is the Send mediator added as a child mediator to the Aggregate mediator in order to send the aggregated and annotated messages back to the client once the aggregation is complete.|
For more examples, see: